Answer to Question #252567 in Python for Hazer

Question #252567

7. Factorials

by CodeChum Admin

For those of you who may not now, a factorial is a product of multiplying from 1 until the number. Now, you must make a program that will accept an integer and then print out its factorial using loops.

Are you up for this task?



1
Expert's answer
2021-10-17T09:29:45-0400
def factorial(num):
    fac = 1

    for i in range(1, num + 1):
        fac = fac * i
    return("factorial of ", num, " is ", fac)
factorial(8)

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS