Skip to content

Instantly share code, notes, and snippets.

@tyler
Created June 3, 2010 03:25
Show Gist options
  • Save tyler/423399 to your computer and use it in GitHub Desktop.
Save tyler/423399 to your computer and use it in GitHub Desktop.
def even?(n)
n % 2 == 0
end
def fast_mult(b, n)
if n == 0
0
elsif even?(n)
fast_mult(b, n / 2) * 2
else
b + fast_mult(b, n - 1)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment