[erlang-questions] Hi all here the RESUME for Pytagorians Numbers Algorithm!!!
Mon Nov 15 10:38:41 CET 2010
2010/11/15 Gilberio Carmenates García <>:
> py3R NO returns the same than 'pythag1' %% I just tries to put the
> Richard explanation in a
> algorithm but, seems to me I
> was wrong here too.
I interpreted Richard's algorithm to be something along the lines of:
A <- lists:seq(1, N div 2),
B <- lists:seq(1, N - A),
C <- [trunc(math:sqrt(A * A + B * B))],
A + B + C =< N,
A*A + B*B =:= C*C].
This version comes out on top when N is in the hundreds and above.
Below this it is omly matched by Morten's algorithm. I would argue
that Richard's is slightly less complex...
More information about the erlang-questions