RosettaCodeData/Task/Golden-ratio-Convergence/ObjectIcon/golden-ratio-convergence.oi
2023-07-01 13:44:08 -04:00

16 lines
354 B
Text

import io, util
procedure main ()
local phi0, phi1, count
count := 1
phi0 := 1.0
while abs ((phi1 := 1.0 + (1.0 / phi0)) - phi0) > 1.0e-5 do
{
phi0 := phi1
count +:= 1
}
io.write ("Result: ", phi1, " after ", count, " iterations")
io.write ("The error is approximately ",
phi1 - (0.5 * (1.0 + Math.sqrt (5.0))))
end