How can I write an algorithm that calculates the factorial of a number?
Answer
14
Follow
Request
More
Ad by Jigsaw Academy
Accelerate your career with India's premier analytics institute.
Stand out from the crowd and become job-ready with our exclusive PGDPM program in Bengaluru.
Learn More
12 ANSWERS

Nishan Pantha, computer engineer, developer, programmer, dynamic programming
Answered Sep 18, 2015
Here I am not going to write some code because you havent mentioned about the "programming language".
Basically for factorial you just have to multiply all the numbers from 1 to the given number which is just a simple paper-pencil technique.
So, the algorithm for the factorial goes like this:
input a number n
set variable final as 1final <= final * n
decrease n
check if n is equal to 0if n is equal to zero, goto step 8 (break out of loop)else goto step 3
print the result final
By Nishan Pantha