Calculate factor
Write a program that receives a number of input and the factoriel calculates and prints it
Write a program that receives a number of input and the factoriel calculates and prints it
def factorial(n):
if n == 0:
return 1
else:
return n * factorial(n - 1)
num = int(input("عدد را وارد کنید: "))
print(f"فاکتوریل {num} برابر است با {factorial(num)}")
let msg = 'error' alert(msg)This answer is only visible to premium members
This answer is only visible to premium members
let msg = 'error' alert(msg)This answer is only visible to premium members
This answer is only visible to premium members
let msg = 'error' alert(msg)This answer is only visible to premium members
This answer is only visible to premium members
p=int(float(input("num:")))
s=1
for o in range(1,p+1):
s=s*o
print("f:",s)
# This code takes the user's desired number
number = int(input('enter number: '))
# Sam is the abbreviation of the samment
sum = 1
while number > 0: # This code also calculates the factor of the user
sum *= number
number = number - 1
print(sum) # Finally the user number factor is printed
X=int(input("x:")) import math print(math.factorial(X))
num = int(input("number: "))
s = 1
for i in range(1 , num+1):
s = s * i
print("----{}----".format(s))
def factorial(num): if num == 1: return 1 return num * factorial(num-1) num = int(input('Enter number:')) print(f'{num}! = {factorial(num)}')
a=int(input("a:")) b=1 for c in range(1,a): b=b*c print(b*a)
Hi I don't understand that part b*c.
Submitting answers is currently unavailable.
You must be logged in to access this section.
Login/Sign up If you don’t understand the exercise or can’t solve it for any reason, that’s completely
normal—don’t worry 😊
Try checking out easier exercises and reviewing different answers
submitted by others. Gradually, you can move on to more challenging exercises. Also, your answer
might be correct even if it’s different from others.