LoginSignup
0
0

More than 3 years have passed since last update.

Ruby学習#24 Exponent Method

Posted at

def pow(base_num, pow_num)
result = 1
pow_num.times do |index|
result = result * base_num
end
return result
end

puts pow(2,3)

8

puts pow(4,3)

64

|index| なくても同じ

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0