Skip to content

Commit 18c3a0f

Browse files
Create fibonaci of certain number
findind fibonacci series
1 parent c5c05c2 commit 18c3a0f

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

Diff for: fibonaci of certain number

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
include <stdio.h>
2+
int main() {
3+
int t1 = 0, t2 = 1, nextTerm = 0, n;
4+
printf("Enter a positive number: ");
5+
scanf("%d", &n);
6+
7+
// displays the first two terms which is always 0 and 1
8+
printf("Fibonacci Series: %d, %d, ", t1, t2);
9+
nextTerm = t1 + t2;
10+
11+
while (nextTerm <= n) {
12+
printf("%d, ", nextTerm);
13+
t1 = t2;
14+
t2 = nextTerm;
15+
nextTerm = t1 + t2;
16+
}
17+
18+
return 0;
19+
}

0 commit comments

Comments
 (0)