Im having calculating the right value for the 2.5 input, the function is the problem but I don't know where the problem in my calculation is. The outcome is supposed to be 12.18249396 but i comes out short.
float seq(float exp)
{
float prev(0.0),atol(0.0),icnt(1.0);
prev = 1.0 + (1.0 * exp/icnt);// begin of sequence
do
{
icnt++; // next sequence
prev = prev * (exp/icnt);//get total to add
atol = atol + prev;// pools the additions
}
while(prev > 0);// condition
return atol; //total value of pool
}
/*Test data
Input the number to do convergence sequence:
2.5
convergence total is: 12.155492
Press any key to continue . . .*/