On Fri, 17 Jan 2003 09:21 am, civileme wrote:
> On Friday 17 January 2003 10:39 am, _nasturtium wrote:
> > But think about it. By the time we reach the 10th level there's already
> > over 10 million copies of mandrake!
> >
> > _nasturtium
>
> Hmmm,
>
> Well we have a semantics problem perhaps.
>
> 1st level is the guy who gets one copy  or pow(5,0)=1
> 10th level should be pow(5,9) copies, or slightly less than 2 million
> Previous level is less than 400,000 and total copies out there is like less
> than 2.500,000.
>
> Perhaps you count the first level as the zeroth?  Then by the 10th level we
> have more than 12,000,000 copies out there
>
> #!/usr/bin/env python
> import math
> total=0.0
> for i in range(11):
>       x=float(i)
>       y=math.pow(5.0,x)
>       total=total+y
>       print i, y, total
>
>
> [tester@ibm333 tester]$ ./5calc.py
> 0 1.0 1.0
> 1 5.0 6.0
> 2 25.0 31.0
> 3 125.0 156.0
> 4 625.0 781.0
> 5 3125.0 3906.0
> 6 15625.0 19531.0
> 7 78125.0 97656.0
> 8 390625.0 488281.0
> 9 1953125.0 2441406.0
> 10 9765625.0 12207031.0
> [tester@ibm333 tester]$
>
>
> civileme
Hello!
        First, nice to see you back! Well, I guess I do count the first level as 
zeroth.
        Here's something I was working on in QT: a fibonacci calculator for KDE (GPL 
of course, open-source, a BASIC version available, and my major contribution 
to the linux community). Obviously it calculates fibonacci values. 
I'll send along the project file, main cpp and ui file if you like (off-list). 
This is an extract of the code (cut down the extra niceties):

#include <math.h>
void FibnForm::PushButton5_clicked()
{
    QString happy = InputNum->text();
    double therequest=0;
  
    therequest = atoi(happy.utf8 ());
        //add this line to set the first fib value to 0   
        //therequest-=3;

 LCDNumber1->display(Calcul(therequest));
}
double FibnForm::Calcul(double todo)
{
    return( (sqrt(5) + 3) / (5 - sqrt(5)) * pow ((2 / (sqrt(5) - 1)), todo 
)+(3 - sqrt(5)) / (5 + sqrt(5)) * pow ( (2 / (-1 - sqrt(5))) , todo) );
 }

You can of course just make a main () function and compile it. Run it. 
Surprised? The first fibonacci is actually 2! So that's why i have the line 
therequest-=3, because users expect it to be 0, or 1. The -3rd term is 0.

And you might be wondering: why did I use such a complex formula to calculate 
fibonacci when i could have just used iteration or recursion? Well, because 
it's elegant, and I proved it myself :-)

Regards,
        _nasturtium

(next project: russian multiplication)

Want to buy your Pack or Services from MandrakeSoft? 
Go to http://www.mandrakestore.com

Reply via email to