Question: (Python 3) Given below is a function is_factorial that takes a positive integer as parameter. It should print True if n is equal to factorial

(Python 3) Given below is a function is_factorial that takes a positive integer as parameter. It should print True if n is equal to factorial of a positive integer and otherwise False. But in the current form it does not work correctly. Please correct the given function to print the expected output.

def is_factorial(n): global test i=1 p=i while i <=n: i=i+1 p=p*i if p==n: test=True elif p!=n: test=False print(test) is_factorial(24) is_factorial(15) is_factorial(1)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!