Golden ratio/Convergence: Difference between revisions

Line 261:
<pre>Result: 1.618033 after 14 iterations
The error is approximately -1.201865E-06</pre>
 
==={{header|Craft Basic}}===
<syntaxhighlight lang="basic">precision 6
 
define i = 0, d = 0, phi0 = 1, phi1 = 0
 
do
 
let phi1 = 1 / phi0 + 1
let d = abs(phi1 - phi0)
let phi0 = phi1
let i = i + 1
 
wait
 
loopuntil .00001 > d
 
print "result: ", phi1, " after ", i, " iterations"
print "the error is approximately ", phi1 - (.5 * (1 + sqrt(5)))
 
end</syntaxhighlight>
 
==={{header|FreeBASIC}}===
305

edits