Skip to main content

TOP 10 Mostly asked Basic Programs in python

 

1. Python Program for factorial of a number

Factorial of a number is products of all natural number to till that number.
for eg:
5!=5*4*3*2*1=120
100!=1*2*3*...........................................99*100

Logic: Suppose we have to find the the factorial of a number n then we required to multiply all number starting from 1 to n
n!=1*2*3*4*.........................(n-1)*n!
So we need to multiply all these numbers in this range 1 to n+1
why did I not  take range 1 to n because range function gives values less than 1 
OUTPUT:

Implementation using Loop

                                                         Implementation using  Recursion


Comments