Computer Science, asked by gunjans5542, 8 months ago

Write a program to compute the factorial of a number using recursion. INPUT AND OUTPUT FORMAT: Input consists of an integer. Refer sample input and output for formatting specifications

Answers

Answered by Anonymous
2

Answer:

its apython program

#factorial of number using recusion

def factorial(n):

   if n==1:

       return 1

   else:

       fact=n*factorial(n-1)

   return fact

# main

num=int(input("enter the number"))

print(factorial(num))

#hope it helps you

please mark brainliest

Answered by pratikkohad1999
4

Answer:

#include<iostream>

using namespace std;

int factorial(int n);

int main()

{

int n;

std::cin>>n;

std::cout << "The factorial of "<<n<< " is " <<factorial(n);

return 0;

}

int factorial(int n)

{

if(n > 1)

return n * factorial(n - 1);

else

return 1;

}

Explanation:

all test case passed.

Similar questions