ads

Make a Program For Fibonacci Series İn C++

What is Fibonacci Series 

The Fibonacci series is a sequence of numbers in which each number is the sum of the two preceding ones, usually starting with 0 and 1. The sequence goes 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, and so on. It is named after the Italian mathematician Leonardo Fibonacci, who introduced the series to Western mathematics in his book Liber Abaci, which was published in 1202. The Fibonacci series has many interesting properties and appears in many areas of mathematics, as well as in art, music, and nature.


Program for fibonacci series

#include <iostream> using namespace std; int main() { int n, first = 0, second = 1, next; cout << "Enter the number of terms: "; cin >> n; cout << "Fibonacci Series: "; for (int i = 1; i <= n; ++i) { if(i == 1) { cout << first << " "; continue; } if(i == 2) { cout << second << " "; continue; } next = first + second; first = second; second = next; cout << next << " "; } return 0; }


About Admin

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.

0 yorum :

Yorum Gönder