Program 1: Report File

Clear Doubts with Computer Tutor
In case you’re facing problems in understanding concepts, writing programs, solving questions, want to learn fun facts | tips | tricks or absolutely anything around computer science, feel free to join CTs learner-teacher community:

Program 1: Recursively find the factorial of a natural number

def recur_factorial(n):
  if n == 1:
      return n
      return n*recur_factorial(n-1)

# take input from the user
num = int(input("Enter a number: "))
# check is the number is negative
if num < 0:
  print("Sorry, factorial does not exist for negative numbers")
elif num == 0:
  print("The factorial of 0 is 1")
  print("The factorial of",num,"is",recur_factorial(num))

If you want access to all the programs to be put in your report file, visit a page that contains all programs for your final class 12 computer science report file.

You cannot copy content of this page