Let's say you entered 5, so it will run till 1.

First iteration will be: while 5>0 which is true

fact = fact * 5 while remember fact = 1 so answer will be

fact = 1 * 5

Then number will reduce to -1 i.e. 4

This will repeat until the condition is met.

The final answer looks like as: 5*4*3*2*1 = 120

## Comments

0 comments

Article is closed for comments.