RosettaCodeData/Task/Nth-root/Erlang/nth-root-1.erl
2023-07-01 13:44:08 -04:00

6 lines
255 B
Erlang

fixed_point(F, Guess, Tolerance) ->
fixed_point(F, Guess, Tolerance, F(Guess)).
fixed_point(_, Guess, Tolerance, Next) when abs(Guess - Next) < Tolerance ->
Next;
fixed_point(F, _, Tolerance, Next) ->
fixed_point(F, Next, Tolerance, F(Next)).