hi everyone I feel so stupid asking help for these.
i NEED HELP with these part of my code my prompt said :
(computing Π (PI) ) You can approximate (PI) value by using the following
series:
Π = 4( 1 1/3 + 1/5 1/7 + 1/9 1/11 + - 1/(2i -1) + 1/(2i + 1)
Write a method that calculate value of π by using the above series, using
the following header:
public static double pi()
assume i = 1000000
ok so I have been testing it but I really did get any far :
for ( double i = 1; i< 1000000; i+=2) {
// with these I try to increment the value of i to get to the serie.
//I did these after and test it and the output is all wrong and I know it
sum = (1/((2*i)+1));
sum = sum + (1/((2*i)-1));
sum ++;
double pi = 4*(sum);
// I know is wrong I but I can´t figure it out what to do.
I am a first semester student of computer science I got the beging of the semester really fast but these is getting harder and my professor is not helping that much..
if someone can help me pleaseee!
i NEED HELP with these part of my code my prompt said :
(computing Π (PI) ) You can approximate (PI) value by using the following
series:
Π = 4( 1 1/3 + 1/5 1/7 + 1/9 1/11 + - 1/(2i -1) + 1/(2i + 1)
Write a method that calculate value of π by using the above series, using
the following header:
public static double pi()
assume i = 1000000
ok so I have been testing it but I really did get any far :
for ( double i = 1; i< 1000000; i+=2) {
// with these I try to increment the value of i to get to the serie.
//I did these after and test it and the output is all wrong and I know it
sum = (1/((2*i)+1));
sum = sum + (1/((2*i)-1));
sum ++;
double pi = 4*(sum);
// I know is wrong I but I can´t figure it out what to do.
I am a first semester student of computer science I got the beging of the semester really fast but these is getting harder and my professor is not helping that much..
if someone can help me pleaseee!