SHARE
TWEET

Untitled

a guest Jun 12th, 2019 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def sumatoria_i(n):
  2.     sum = 0
  3.     for i in range(1, n + 1):
  4.         sum += i
  5.     return sum
  6.  
  7. def sumatoria(n):
  8.     if n == 1:
  9.         return 1
  10.     return n + sumatoria(n - 1)
  11.  
  12. def fibonacci(n):
  13.     if n <= 1:
  14.         return n
  15.     return fibonacci(n - 1) + fibonacci(n - 2)
  16.  
  17. def fibonacci_i(n):
  18.     i = 0
  19.     j = 1
  20.     for x in range(n - 1):
  21.         k = i + j
  22.         i = j
  23.         j = k
  24.     return j
  25.  
  26. def suma_digitos(n):
  27.     if n < 10:
  28.         return n
  29.     return n % 10 + suma_digitos(n // 10)
  30.  
  31. def cuenta_pares(n):
  32.     if n < 10:
  33.         if n % 2 == 0:
  34.             return 1
  35.         return 0
  36.     if n % 2 == 0:
  37.         return 1 + cuenta_pares(n // 10)
  38.     return cuenta_pares(n // 10)
  39.  
  40. def x(lista):
  41.     if len(lista) == 1:
  42.         print(lista[0], end=" ")
  43.     else:
  44.         x(lista[1:])
  45.         print(lista[0], end=" ")
  46.  
  47.  
  48. lista = [1, 2, 3, 4, 5, 6]
  49. x(lista)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top