Python Programming Factorial Series

What is factorial series?

Factorial value of 5 (5!): 5 X 4 X 3 X 2 X 1 = 120

Python Program for Factorial Series

#!/usr/bin/python                                                               
                                                                                
def calculate_factorial_val(num):                                               
    if num > 1:                                                                 
       return calculate_factorial_val(num-1) * num                              
    else:                                                                       
        return num                                                              
                                                                                
def get_factorial_serious(limit):                                               
    result = []                                                                 
    count = 1                                                                   
    while(count <= limit):                                                      
        result.append(calculate_factorial_val(count))                           
        count += 1                                                              
    return result                                                               
                                                                                
limit = 10                                                                      
print(get_factorial_serious(limit))                                             
                                

Output:
$ python factorial_series.py 
[1, 2, 6, 24, 120, 720, 5040, 40320, 362880, 3628800]

Privacy Policy  |  Copyright@2017 - All Rights Reserved.  |  Contact us   |  Report website issues in Github   |  Facebook page   |  Google+ page

Email Facebook Google LinkedIn Twitter
^