PI/2=1 + 1/3 + 1/3 + 1/3 2/5 * * * 2/5 3/7 +...
Double PI (double t)
{
Double sum=1, m=1, n.
For (n=1; N<=t; N++)
{
M=n/(2 * n + 1);
Sum=sum + m;
}
Return (sum * 2);
}
CodePudding user response:
Not sure, you bring n=2, in just can't see yaoUnder the condition of n=2, formula is 1/3 * 2/5
You this loop was added in the sum inside a 2/5, by analogy, behind every item does not conform to the
CodePudding user response:
Don't meet; 1/3 * 2/5 this multiplication is not reflected. In addition, the value of t need to do a qualified, not these values are 1, 2,Search on the net, look at other people's logic, consult ~
CodePudding user response:
Yes, also need some supplement, rigorousCodePudding user response:
I think, according to the program's original intention, t should be PI calculation accuracy, as a double incoming, not as judge of the loop condition,