Commit ec5d2ec
committed
feat: Compute factorial of a number using a for loop
🧠 Logic:
- Read user input `n`.
- Initialize `fact` as 1 (to hold the factorial result).
- Loop from 1 to `n`, multiplying `fact` by the loop counter `i` at each step.
- After the loop, print the final factorial value.
Signed-off-by: Somesh diwan <[email protected]>1 parent fded6ba commit ec5d2ec
1 file changed
+3
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
10 | 11 | | |
| 12 | + | |
11 | 13 | | |
12 | | - | |
13 | | - | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| |||
0 commit comments