Skip to content

Instantly share code, notes, and snippets.

@chiragmongia
Created March 18, 2013 05:17
Show Gist options
  • Select an option

  • Save chiragmongia/5185218 to your computer and use it in GitHub Desktop.

Select an option

Save chiragmongia/5185218 to your computer and use it in GitHub Desktop.
class Array
def power(x)
@x = x
@f= []
self.each do |i|
b = i
c = 1
@x.times{ c = c * b }
@f << c
end
puts @f.inspect
end
end
p "Enter the value of power"
num = gets.to_i
a = [1,2,3,4,5]
a.power(num)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment