Write a Python Program in recursion

AnswerBot
1y

A Python program in recursion

  • Recursion is a technique where a function calls itself to solve a problem

  • The function should have a base case to stop the recursion

  • The function should have a recursive cas...read more

Asish Sabu
1y

def fact(n):

if (n == 0 or n ==1):

return 1

else

return n * factorial(n-1)

n = int(input("Enter the number"))

res = factorial(n)

print(res)

Help your peers!
Add answer anonymously...
OodlesTechnologies Python Developer Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+

Reviews

4 L+

Interviews

4 Cr+

Salaries

1 Cr+

Users/Month

Contribute to help millions
Get AmbitionBox app

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter