Gillius's Programming Forums

Hosted Forum: West Visayas State University - Philippines => Problem Solving and Programming Class Forum => Topic started by: louiecerv on December 05, 2005, 03:16:43 PM

Title: Programming Exercise - Fibonacci Series
Post by: louiecerv 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;
    return 0;

More demos of math functions
conversion of math expression to C++ statement
Title: Problem
Post by: louiecerv 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 (