Created Fibonacci Series

This code helps you to print the desired number of the Fibonacci number in a sequence.
This commit is contained in:
Prabhakar Deep 2018-10-07 22:09:46 +05:30 committed by Luke Oliff
parent f1da858734
commit 6c5f934dbb
1 changed files with 15 additions and 0 deletions

15
code/prvkrFibonacci.cpp Normal file
View File

@ -0,0 +1,15 @@
#include <iostream>
using namespace std;
int main() {
int n1 = 0, n2 = 1, n3, num;
cout << "Enter the number of elements: ";
cin >> num;
cout << n1 << " " << n2 << " ";
for(int i = 2; i < num; ++i){
n3 = n1 + n2;
cout << n3 << " ";
n1 = n2;
n2 = n3;
}
return 0;
}