Ramanujan's constant: Difference between revisions

Content added Content deleted
m (→‎{{header|Phix}}: 32 ==> 100 d.p.)
Line 391: Line 391:
{{libheader|mpfr}}
{{libheader|mpfr}}
<lang Phix>include mpfr.e
<lang Phix>include mpfr.e
mpfr_set_default_prec(-120) -- (18 before, 100 after, plus 2 for kicks.)

constant dp_rqd = 18+32+2, -- (18 before, 32 after, plus 2 for kicks.)
precision_rqd = mpz_sizeinbase(mpz_init(repeat('9',dp_rqd)),2)

function q(integer d)
function q(integer d)
mpfr pi = mpfr_init(precision:=precision_rqd)
mpfr pi = mpfr_init()
mpfr_const_pi(pi)
mpfr_const_pi(pi)
mpfr t = mpfr_init(d,precision:=precision_rqd)
mpfr t = mpfr_init(d)
mpfr_sqrt(t,t)
mpfr_sqrt(t,t)
mpfr_mul(t,pi,t)
mpfr_mul(t,pi,t)
Line 405: Line 403:
end function
end function
printf(1,"Ramanujan's constant to 32 decimal places is:\n")
printf(1,"Ramanujan's constant to 100 decimal places is:\n")
mpfr_printf(1, "%.32Rf\n", q(163))
mpfr_printf(1, "%.100Rf\n", q(163))
sequence heegners = {{19, 96},
sequence heegners = {{19, 96},
{43, 960},
{43, 960},
Line 413: Line 411:
}
}
printf(1,"\nHeegner numbers yielding 'almost' integers:\n")
printf(1,"\nHeegner numbers yielding 'almost' integers:\n")
mpfr t = mpfr_init(precision:=precision_rqd), qh
mpfr t = mpfr_init(), qh
mpz c = mpz_init()
mpz c = mpz_init()
for i=1 to length(heegners) do
for i=1 to length(heegners) do
Line 429: Line 427:
{{out}}
{{out}}
<pre>
<pre>
Ramanujan's constant to 32 decimal places is:
Ramanujan's constant to 100 decimal places is:
262537412640768743.9999999999992500725971981856888793538563373369908627075374103782106479101186073129511813461860645042
262537412640768743.99999999999925007259719818568888


Heegner numbers yielding 'almost' integers:
Heegner numbers yielding 'almost' integers: