Skip to content

Commit

Permalink
mouredev#6 - Python
Browse files Browse the repository at this point in the history
  • Loading branch information
jptxaya committed Jun 13, 2024
2 parents 8438bb9 + 7100176 commit c20c487
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions Roadmap/06 - RECURSIVIDAD/python/jptxaya.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@

#Recursividad
def funcion_contar_atras(mint):
if mint < 0:
return
print(mint)
funcion_contar_atras(mint - 1)

funcion_contar_atras(100)

#Dificultad Extra
print("Dificultad Extra")
def factorial(my_int):
if my_int == 1:
return 1
result = factorial(my_int -1) * my_int
return result

print("Calcular factorial")
factor = int(input("Introducir numero a calcular:"))
print(f"Resultado:{factorial(factor)}")

def posicion_fibonacci(my_pos):
if my_pos == 0:
return 0
elif my_pos == 1:
return 1
else:
return posicion_fibonacci(my_pos - 2) + posicion_fibonacci(my_pos - 1)


print("Calcular numero en posicion Fibonacci")
posicion = int(input("Introducir posicion:"))
print(f"Resultado:{posicion_fibonacci(posicion)}")

0 comments on commit c20c487

Please sign in to comment.