avkLab

Fibonacci

Jun 12th, 2022
1,013
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.65 KB | None | 0 0
  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. #----------------------------------------------------------------------------
  4. # Created by  : Alain Van Kerckhoven
  5. # Created Date: 14 janvier 2015
  6. # Licence     : GPL
  7. # Version     : 1.0
  8. # ---------------------------------------------------------------------------
  9. """
  10. Calcule le ne nombre de Fibonacci (méthode récursive)
  11. """
  12. # ---------------------------------------------------------------------------
  13.  
  14. def fibo(n):
  15.    if n <= 1:
  16.        return n
  17.    else:
  18.        return(fibo(n-1) + fibo(n-2))
  19.  
  20. nb = int(input("Introduisez un nombre : "))
  21.  
  22. Fn = fibo(nb)
  23.  
  24. print("F("+ str(nb)+") = "+str(Fn))
  25.  
Advertisement
Add Comment
Please, Sign In to add comment