Commit f736005
committed
feat: Generate Fibonacci series up to n terms using iterative loop
🧠 Logic:
- Read `n` from user input representing number of terms to generate.
- Start with base values: a = 0, b = 1.
- Print the first two terms (0, 1).
- Loop from 0 to n-2 to generate remaining terms:
- Compute next term `c = a + b`.
- Print `c`, then update `a = b` and `b = c`.
Signed-off-by: Somesh diwan <[email protected]>1 parent ecfef82 commit f736005
1 file changed
+3
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
15 | | - | |
16 | | - | |
| 16 | + | |
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
0 commit comments