Saturday, February 28, 2009

Raising a number to the power of another number. exponent. in haskell

power :: Float -> Float -> Float
power m n
| n == 0        = 1
| n > 0         = m* power m (n-1)
| otherwise     = (1 / m)* power m (n+1)

No comments:

Post a Comment