How can we print factorial no. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How can we print factorial no.

19th Sep 2020, 5:29 PM
Rohit Solanki
Rohit Solanki - avatar
3 Answers
+ 5
With your logic.
19th Sep 2020, 5:31 PM
The future is now thanks to science
The future is now thanks to science - avatar
+ 4
First enter any number for example you Entered 5 then you have to decrease Entered number by 1 and u have to make logic for multiply Entered number and decreased no. And store it in another variable. And again decrease no and multiply it into stored number do same process when u reach at 1 you have to exit and print values . You can use recursion or using for loop with if condition
19th Sep 2020, 5:57 PM
A S Raghuvanshi
A S Raghuvanshi - avatar
0
Recursion is a good option. If you use iteration, I'd go for a while loop.
19th Sep 2020, 7:42 PM
benjamin