-
-
Save hyuki0000/f99c07dbdad0aa1ce23592c7ec0b6e48 to your computer and use it in GitHub Desktop.
冪乗
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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