Find factorial of a number using recursion in c++

Avinash
1 min readJul 24, 2020
A laptop for programming
Photo by Maxwell Nelson on Unsplash

#include <iostream>
using namespace std;

int fact(int number){
if(number == 1){
return 1;
}
else{
return number*fact(number-1);
}
}

int main() {
int n;
cout<<”Enter number to find factorial”<<endl;
cin>>n;
int factorial = fact(n);
cout<<”factorial of number “<<n<<” is “<<factorial<<endl;
return 0;
}

Conclusion: We have seen how to find factorial of a number using recursion in c++ language.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Avinash
Avinash

Written by Avinash

I am a passionate programmer and full stack developer. I love to study about data structures and algorithms. Here generally write about javascript , ReactJs..

No responses yet

Write a response