Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- # -*- coding: utf-8 -*-
- #----------------------------------------------------------------------------
- # Created by : Alain Van Kerckhoven
- # Created Date: 6 mars 2017
- # Licence : GPL
- # Version : 1.0
- # ---------------------------------------------------------------------------
- """
- calcule la factorielle d'un nombre (méthode récursive)
- """
- # ---------------------------------------------------------------------------
- def fact(x):
- if x < 2:
- return 1
- else:
- return x * fact(x - 1)
- nb = int(input("Introduisez un nombre : "))
- factorielle = fact(nb)
- print(str(nb) + "! = " + str(factorielle))
Advertisement
Add Comment
Please, Sign In to add comment