Jump to content

Golden ratio/Convergence: Difference between revisions

add raku solution
(add raku solution)
Line 1,256:
Error (approx) : -0.00000120186465
</pre>
 
=={{header|raku}}==
<syntaxhighlight lang="raku">constant phi = 1.FatRat, 1 + 1/* ... { abs($^a-$^b)≤1e-5 };
 
say "It took {phi.elems} iterations to reach {phi.tail}";
printf "The error is {{ ($^a - $^b)/$^b }(phi.tail, (1+sqrt(5))/2)}"</syntaxhighlight>
{{out}}
<pre>It took 15 iterations to reach 1.618033
The error is -7.427932029059675e-07</pre>
 
=={{header|RATFOR}}==
1,934

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.