3
How to define recursively in terms of multiplication, the power function, where a base is raised to a non-negative integer exponent?
Code:
expo (x, y) y > 0 fun(pot) return x*expo(x, y-1)
3
How to define recursively in terms of multiplication, the power function, where a base is raised to a non-negative integer exponent?
Code:
expo (x, y) y > 0 fun(pot) return x*expo(x, y-1)
2
Less compact but works.
potencia:: Int->Int->Int
potencia x n |(n<0) = error "Expoente negativo."
|(n==0) = 1
|(n==1) = x
potencia x n = x * potencia x (n-1)
Browser other questions tagged recursion haskell
You are not signed in. Login or sign up in order to post.
What have you done so far?
– novic
expo (x, y) y > 0 fun(pot) Return x*expo(x, y-1)
– BulletSentence
Saw there Bulletsentence I put right in the question, whether can edit and do the same blz
– novic