0

for loop

why i should but fact=1; (which i but in line 13) in the loop to get correct outbut could anybody explains http://ideone.com/0B1yfH

22nd Aug 2019, 1:28 PM
Mahmoud Hamed
Mahmoud Hamed - avatar
2 Réponses
+ 2
If you do not reinitialise fact to 1, the old value stored in fact will be used to calculate the factorial of the number in the next iteration of the outer loop.
22nd Aug 2019, 1:30 PM
Hatsy Rei
Hatsy Rei - avatar
+ 1
i got it thank you
22nd Aug 2019, 1:32 PM
Mahmoud Hamed
Mahmoud Hamed - avatar