Skip to content

Commit

Permalink
Fix Asiatik#361: Add Fibonacci for C++ (Asiatik#362)
Browse files Browse the repository at this point in the history
* Fix Asiatik#361: Add Fibonacci for C++

* Made into Function
  • Loading branch information
struong9 authored and tstreamDOTh committed Oct 29, 2018
1 parent 7a79ac1 commit dceab34
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions Maths/Fibonacci/C++/Fibonacci.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#include <iostream>

using namespace std;

void fibonacci(int number)
{
int first = 0, second = 1, next;

for (int i = 0; i < number; i++)
{
cout << "\n" << first;
next = first + second;
first = second;
second = next;
}
}

int main()
{
int number;

cout << "Enter number of terms for Series: ";
cin >> number;

cout << "Fibonacci Series are: \n";
fibonacci(number);
}

0 comments on commit dceab34

Please sign in to comment.