Continued fraction: Difference between revisions
m
→{{header|Phix}}: simplify: use functions with multiple returns
m (→{{header|Haskell}}: Guards in place of an if then else.) |
m (→{{header|Phix}}: simplify: use functions with multiple returns) |
||
Line 2,051:
=={{header|Phix}}==
<lang Phix>constant precision = 10000▼
atom res = 0▼
for n=steps to 1 by -1 do▼
res := fb(n) / (fa(n) + res)▼
end for▼
return fa(0) + res▼
end function▼
function
▲ atom a, b, res = 0
function sqr2_b(integer n) return 1 end function▼
▲ for n=steps to 1 by -1 do
{a, b} = f(n)
▲ end for
{a} = f(0)
▲end function
function
function
▲constant precision = 10000
printf(1,"Precision: %d\n", {precision})
printf(1,"Sqr(2): %.10g\n", {continued_fraction(
printf(1,"Napier: %.10g\n", {continued_fraction(
printf(1,"Pi: %.10g\n", {continued_fraction(
{{Out}}
<pre>
|