I need give form ti

I want to shape this mathematical exercise 1-1 / 3 + 1 / 5-1 / 7 + 1/9...... to an algorithm


I get mmm 1 / 2n -1 but I'm not sure ... please help ..
Last edited on
you can use 0 instead, 'cuz 1-1/x = 0/x = 0, if you need to use it, it's also equal to: 0/4/4/8/8... forgot about priority of operators. Will this work:
1
2
3
4
5
6
7
const unsigned x = 9;
double al = 1;
for (unsigned i = 1; i <= x; ++i)
	if (i % 2)
		al -= 1.0 / (2 * i + 1); // 1.0 is important
	else
		al += 1.0 / (2 * i + 1); // 1.0 is important 
Last edited on
OH gracias !!! digo thanks men
De nada :)
Topic archived. No new replies allowed.