### Author Topic: Programming Exercise - Fibonacci Series  (Read 7012 times)

#### louiecerv

• Moderator
• User
•     • Posts: 85 ##### Programming Exercise - Fibonacci Series
« on: December 05, 2005, 03:16:43 PM »
Code: [Select]
`/*    Title:  Fibonacci Series    Author: LF Cervantes    Date:   Dec. 3, 2005*/#include <iostream>#include <cmath>using namespace std;int main(){    cout << "-- FIBONACCI SERIES --\n";    cout << "A program to compute the Nth value the \n"         << "Fibonacci series.\n\n";    cout << "Enter N: ";    int N, FN;        cin >> N;        FN = static_cast<int>(1/sqrt(5)*( pow((1+sqrt(5))/2,N) - pow((1-sqrt(5))/2,N) ));    cout << "The Nth number in the series when N=" << N         << " is " << FN << endl;             system("PAUSE");    return 0;}`

Highlights
More demos of math functions
conversion of math expression to C++ statement
Analyze. Design. Develop. Debug. Deploy. Maintain.

#### louiecerv

• Moderator
• User
•     • Posts: 85 ##### Problem
« Reply #1 on: December 05, 2005, 04:28:44 PM »
Leonardo Fibonacci of Pisa was one of the greatest mathematicians of the Middle Ages.  He is most famous for the Fibonacci sequence that can be applied to many diverse problems.

The Nth Fibonacci number in the sequence can be evaluated with the formula: Write an application that accepts N and displays FN.

The math functions produce result as double.  You need to cast the final value to integer.

Study Solution
Analyze. Design. Develop. Debug. Deploy. Maintain.