1.1 Recursive recursive implementation: calculate the factorial of a number

DEF F (X):
     IF X> =. 1 :
         return X * F (. 1-X )
     the else :
         return . 1 
A = int (INPUT ( " Enter a number " ))
 Print (F (A))

Output results:

Please enter a number. 5
 120 

Process Finished Exit with code 0

 

Guess you like

Origin www.cnblogs.com/hrv5/p/11973562.html