Commit ec43a17
committed
feat: Calculate factorial of a number using while loop
🧠 Logic:
- Start with `n = 6` and initialize `result = 1`.
- Multiply `result` by `n` in each iteration and decrement `n` by 1.
- Continue until `n` reaches 0.
- This computes `6! = 6×5×4×3×2×1 = 720` and prints the result.
Signed-off-by: Somesh diwan <[email protected]>1 parent 1364e2b commit ec43a17
1 file changed
+3
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
6 | | - | |
7 | | - | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| |||
0 commit comments