+ 2
Factorial program in python
What is answer in a question ❓
9 Antworten
+ 4
If you need help, describe the issue.
Do not spam solutions. Q&A is for asking programming related questions and getting help with code.
+ 4
Deepak Royal Gold 🥇🎯💕
Here is a code that might help you with factorial(s)
https://sololearn.com/compiler-playground/c1c5PcVpyU7h/?ref=app
+ 4
print(8*7*6*5*4*3*2*1)
Yes is the same as
print(1*2*3*4*5*6*7*8)
+ 3
WHAT is your question?
+ 2
def factorial_iterative(n):
result = 1
for i in range(1, n + 1):
result *= i
return result
# Example usage
num = 8
print(f"The factorial of {num} is {factorial_iterative(num)}")
+ 1
Same code something change 😕
0
#python code
def fac(n):
if n == 1:
return 1
else:
return n * fac(n - 1)
k = int(input())
print(fac(k))
0
#Program to factorial of a given number
i = 1
fact = 1
while i < = n:
fact = fact * i
i + = 1
print(f "the factorial of a number {n} is {fact}")
0
Hello world 🌍