Skip to content

Commit

Permalink
Implemented generation of Fibbonacci Sequence terms.
Browse files Browse the repository at this point in the history
Implemented the algorithm for generation of Fibbonacci Sequence terms .
This is an iterative approach to generate and print the first N (input) numeber of terms of the fibonacci sequence .
NOTE: the fibonacci sequence has its first and second terms as 0 and 1 respectively .
  • Loading branch information
octosapien authored Oct 19, 2022
1 parent 3c1cf79 commit d990287
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions Fibonacci_SEQ.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include<iostream>
using namespace std;
void fib(int n) {
int f[n];
int i;
f[0] = 0;
f[1] = 1;
for (i = 2; i < n; i++) {
f[i] = f[i-1] + f[i-2];
}
for (i = 0; i < n; i++) {
cout<<f[i]<<" ";
}
}
int main () {
int n = 10;
fib(n);
getchar();
return 0;
}

0 comments on commit d990287

Please sign in to comment.