This question has already been answered:
- The fastest factorial 8 answers
Tell me how to calculate and display factorial, through return?
This question has already been answered:
Tell me how to calculate and display factorial, through return?
A similar question was asked earlier and an answer has already been received. If the answers provided are not exhaustive, please ask a new question .
Just count -
unsigned int factorial(unsigned int n) { unsigned int resulr = 1; if (n > 1) while(n > 1) res *= n--; return res; } But the return not intended to be displayed on the screen; use, for example, the printf function.
In general, it is necessary through if the value of nb <1 fits in. Where nb is a factorial, and then everything is completed and else nb> 1 and then n ++. At the end of the output return nb;
return still perform output to the screen? - Harryreturn printf(...); or return factorial(n); and then echo $? in the console echo $? . - KoVadimSource: https://ru.stackoverflow.com/questions/699288/
All Articles