Commit 2b8ca1b
committed
feat: Calculate sum of first 'n' natural numbers using while loop with user input
🧠 Logic:
- Take user input `n` for number of terms.
- Initialize `sum = 0` and `counter = 1`.
- Use a `while` loop to add each number from 1 to `n` to `sum`.
- Print the result after the loop ends.
Signed-off-by: Somesh diwan <[email protected]>1 parent a4b1160 commit 2b8ca1b
1 file changed
+20
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
0 commit comments