mirror of
https://github.com/c0de-archive/hacktoberfest-2018.git
synced 2024-12-22 05:12:40 +00:00
Created Fibonacci Series
This code helps you to print the desired number of the Fibonacci number in a sequence.
This commit is contained in:
parent
f1da858734
commit
6c5f934dbb
15
code/prvkrFibonacci.cpp
Normal file
15
code/prvkrFibonacci.cpp
Normal 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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user