Skip to content

Instantly share code, notes, and snippets.

@hyuki0000
Created January 25, 2017 12:41
Show Gist options
  • Save hyuki0000/f99c07dbdad0aa1ce23592c7ec0b6e48 to your computer and use it in GitHub Desktop.
Save hyuki0000/f99c07dbdad0aa1ce23592c7ec0b6e48 to your computer and use it in GitHub Desktop.
冪乗
def f(n,m)
if n == 0
1
else
m * f(n-1,m)
end
end
puts "f(2,2) = #{f(2,2)}"
puts "f(10,2) = #{f(10,2)}"
puts "f(5,f(2,2)) = #{f(5,f(2,2))}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment