Computer Science, asked by neha866422, 7 months ago

Write a function fact in python which takes n as parameter and print or return factorial of n.​

Answers

Answered by allysia
3

Here you go:

______________________________

def factorial(n):

   if n==0:

       return 1

   else:

       pro=1

       for i in range(1,n+1):

           pro*=i

       return pro

_______________________________

Answered by jai696
3

\large\mathsf\color{pink}{Solution\: using\: python\: 3}

def factorial(n):

if n == 1 or n == 0:

return 1

res = 1

for x in range(1, n + 1): res *= x

return res

n = int(input("enter n: "))

print(f"{factorial(n)}")

\large\mathsf\color{lightgreen}useful?\: \color{white}\longrightarrow\: \color{orange}brainliest!

Similar questions