I need to define a function power(a,b) that takes the value a and repeats it b times and stores it in an array. Then takes the product of that array.
The idea is to be able to take any number a and raise it to the power of b using arrays.
Anything like this?
def power(a, b) Array.new(b, a).inject(1, :*) end power(2, 3) => 8 power(2, 4) => 16