Factorial of a number | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Factorial of a number

Do the factorial of a number using a recursive function

31st Oct 2017, 1:07 PM
Felipe Lucas Otero
Felipe Lucas Otero - avatar
3 Answers
+ 2
int fact(int num) { if(num>1) { return num*fact(num-1); }else if(num==1){ return 1; }
31st Oct 2017, 1:44 PM
shobhit
shobhit - avatar
31st Oct 2017, 1:50 PM
DAB
DAB - avatar
17th Nov 2017, 9:33 AM
#RahulVerma
#RahulVerma - avatar