# write a program to calculate the sum of the factorial of a number.
n=int(input('enter the POSITIVE no for which you want factorial'))
s=0
if n==0:
print('the factorial of 0 = 1')
if n==1:
print('the factorial of 1 = 1')
if n>=2:
c=1
for i in range(1,n+1):
for j in range (i,0,-1):
c=c*j
s=s+c
print('The factorial of ',n,'is',c)
else:
print('You entered wrong value')
n=int(input('enter the POSITIVE no for which you want factorial'))
s=0
if n==0:
print('the factorial of 0 = 1')
if n==1:
print('the factorial of 1 = 1')
if n>=2:
c=1
for i in range(1,n+1):
for j in range (i,0,-1):
c=c*j
s=s+c
print('The factorial of ',n,'is',c)
else:
print('You entered wrong value')
Comments
Post a Comment
THANK YOU FOR COMMENTING !
PLEASE SUBSCRIBE TO OUR WEBSITE FOR LATEST UPDATES