Wednesday, February 27, 2019

Factorial by using In-Built & Looping Function - Python3

import math
num=int(input('Enter Number: '))
factorial=1;

if num == 0:
    print('The factorial of 0 is 1')
else:
print('\nUsing In-Built Math')
print(math.factorial(num))

print('\nUsing Loop')
for i in range(1,num + 1):
factorial = factorial*i
print(factorial)

ScreenShot:

No comments:

Post a Comment