View Single Post
Old Oct 9th, 2006, 3:01 PM   #14
Dietrich
Professional Programmer
 
Dietrich's Avatar
 
Join Date: Feb 2005
Posts: 434
Rep Power: 4 Dietrich is on a distinguished road
Talking

Quote:
Originally Posted by baldy1324 View Post
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
This is a rather half-baked thread, since by far the slowest performer will be the output to the display and it is part of the loop. So go back and do your homework!
__________________
I looked it up on the Intergnats!
Dietrich is offline   Reply With Quote