This may be more appropiate in the Computer Programming forum but. . .  
A book I'm working on has me generating a table for an equation.  
I decided to do the old "Exponential Growth/Decay" formula 
N=N(0)*e^(k*t)
Where e = natural log 
k= rate of growth or decay 
t= time. 
I wrote a C++ function: 
Code:
double calculateExp(double timeZero, int duration, double rate){ 
       //Sub variable 
       double growthFactor; 
       
       //determine growthFactor 
       growthFactor = rate * duration; 
       //Complete the equation  
       return timeZero*(exp(growthFactor)); 
}
Here's what I came up as a problem: 
Starting with 1000 bacteria, with a rate of decay of .112 how many bacteria are left at the end of each hour. 
So my inputs were: 
Initial Value=1000
rate =-.112 (decay) 
Time = 10. 
The results were: 
Quote:
1 hour = 894
2 ''      = 799
3 ''      = 714 
4 ''      = 638
5 ''      = 570 
6 ''      = 509 
7 ''      = 455
8 ''      = 406 
9 ''      = 362
10       = 323 
 
The code that generated this table was 
Code:
for (int length = 1; length <= time ; length++){ 
        cout << "Time: "; 
        result = calculateExp(value, 1, rateOfChange); 
        value = (int)result; 
        cout << value << endl;   
    }