View Single Post
Old Oct 8th, 2006, 4:46 PM   #1
baldy1324
Newbie
 
Join Date: Oct 2006
Location: texas
Posts: 3
Rep Power: 0 baldy1324 is on a distinguished road
fibonacci sequence

hi i am diving into programming and wanting to find out the amount of time it takes to execute a fibonacci sequence program. i have had past expirience with c++ so i have that code. to make sure the way the program runs is the same, i would like it if this program used while loops, and other similar things. here is the c++ code -
#include <iostream>
using namespace std;

int main()
{
        int n = 1000;
        double first = 0;
        double second = 1;
        cout<<first<<"    "<<second<<"    ";

        while (n--)
                {
                        double third = first + second;
                        first = second;
                        second = third;
                        cout<<third<<"    ";
                }
}

so if anyone can "convert" this to python it would be appreciated
baldy1324 is offline   Reply With Quote