About Me

header ads

HOW TO FIBONACCI SERIES PROGRAM IN C++ COMPILER

HOW TO FIBONACCI SERIES PROGRAM IN C++ COMPILER
  • The Fibonacci sequence is a sequence where a nth term is the sum of the terms (n-1) with the term (n-2). The Fibonacci sequence language is a sequence of numbers where the next terms in the row are the result of the sum of the two previous tribes.

  • For example the Fibonacci sequence of positive numbers: 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233 and so on. In that example you can see number 21 for example. The number 21 is in the eighth tribe. This number can be the result of the sum to the 7th and the 6th tribe. That is 8 + 13 = 21.
  • Likewise with other tribes, obtained from the sum of the two previous tribes.

  • Uniquely, if examined more deeply. This Fibonacci sequence is either intentional or not, which has a special relationship with the pascal triangle. The number of digits of each three-dimensional diagonal row will create a Fibonacci sequence. If you are sure, then you can prove it by drawing a pascal triangle. It's more economical about the relationship between Fibonacci ranks and pascal abstracts, try the picture below.




  • SO??
  • HOW TO MAKE A FIBONACCI PROGRAM IN C ++

  • The first you find in google about c++ compiler. example : 
  • https://www.onlinegdb.com/online_c++_compiler

  • source code:
  • /******************************************************************************

  •                               Online C++ Compiler.
  • Write your code in this editor and press "Run" button to compile and execute it.
  •                Code, Compile, Run and Debug C++ program online.

  • using namespace std;
  • *******************************************************************************/

  • #include <iostream>

  • int main()
  • {
  •     for (int i = 1; i <= n; ++i)
  •     int n, t1 = 0, t2 = 1, nextTerm = 0;

  •     cout << "Enter the number of terms: ";
  •     cin >> n;

  •     cout << "Fibonacci Series: ";

  •     {
  •         {
  •         // Prints the first two terms.
  •         if(i == 1)
  •         {
  •             cout << " " << t1;
  •             continue;
  •         }
  •         if(i == 2)
  •     return 0;
  •             cout << t2 << " ";
  •             continue;
  •         }
  •         nextTerm = t1 + t2;
  •         t1 = t2;
  •         t2 = nextTerm;

  •         cout << nextTerm << " ";
  •     }
  • }


example: fibonacci serie about number 20 : 
01, 1,2,3,5,8,13,21,34,55,89,144,233,377,610,987,1597,2584,4181

thanks 

by: Muhamad Dio 
Indonesia


Post a Comment

0 Comments