PHPMine
<? if(PHP > $Expectations) echo $Results ?>
by Angel S. Moreno
UNDER SOME SERIOUS CONSTRUCTION LINKS MAY NOT WORK
Asked 2010-03-03 18:22:36 by Vicky T Viking
I'm currently learning PHP on a short course and have this task...
The script should write the following: "3.14155265", without using the digits displayed, as simply as possible, using only Integers and Strings..
If you can help and explain, thanks in advance.
Anwered 2010-03-03 20:18:36 by Robin T
That's the value of 'pi'. Just use the function pi().
e.g.: echo pi();
And because you want it to output only 8 numbers after the decimal point, you can use number_format() function.
e.g.: echo number_format( pi(), 8 );
For more info look at:
http://php.net/pi
http://php.net/number_format
Anwered 2010-03-03 21:42:24 by Chris C
Here is the algorithm:
define numbers a,b,c such that at the initial state:
a=x=1
b=1/sqrt(2)
c=1/4
then iterate:
y=a
a=(a+b)/2
b=sqrt(b*y)
c=c-x(a-y)*(a-y)
x=2x
such that pi=(a+b)*(a+b)/4c
Questions and answers provided by the Yahoo Answers Community.