Advertisement
iavellaneda

recursion haskell

Apr 20th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- Eleva un numero a un exponente utilizando recursion
  2. potencia base 0 = 1
  3. potencia base exp = base * potencia base (exp-1)
  4.  
  5. -- Cuenta los digitos de un numero
  6. cuentaDigitos 0 = 1
  7. cuentaDigitos x = 1 +  if x `div` 10 /= 0 then
  8.   cuentaDigitos (x `div` 10)
  9.   else
  10.     0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement