- 2

def calc_fact(a): if(a>0): else: n=int(input("Please input any positive number to calculate it's factorial\n")) print "

Help in this code

8th Jan 2022, 2:37 PM
Anshika Gautam
1 Answer
0
Technically, factorial of 0 should be 1. Please find your required code below: def calc_fact(a): if(a==0): return 1 if(a>0): return a*calc_fact(a-1) return 1 def check_input(a): if(a<0): check_input(int(input("Please enter a positive integer for its factorial\n: "))) else: print("factorial of {} is {}".format(a, calc_fact(int(a)))) check_input(int(input("Please enter a positive integer for its factorial\n: ")))
1st Jun 2022, 2:54 PM
Pardha Saradhy
Pardha Saradhy - avatar