geometric series

I actually got this program working for what I need, but for some reason every time I try to rewrite this while loop, to not use the pow() it hangs.... help please.

1
2
3
4
5
6
7
8
9
 while (fabs(suma-sumb) > fabs(a*0.0000000001))
	{
	int b =i-1;
	
	number = a*(pow(r,b)); //yes I know not optimal
	sumb =sumb +number; //compute the sum by adding the number
	i++;
	terms = i;
	}
You used the: #include<cmath> library facility right?
I don't see anything wrong with your program, for it to hang.
I'm sorry for the misunderstanding, I put up the code that works... not the several, that I'm having hang. I'm hoping for someone to rewrite this line: "number = a*(pow(r,b));" without the pow(), b/c its eluding me.
Topic archived. No new replies allowed.