Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## foo.erl
- -module(foo).
- -export([pythag/1]).
- pythag(N) -> lists:usort(pythag_list(N)).
- pythag_list(N) ->
- [ lists:usort([A, B, C]) ||
- A <- lists:seq(1, N),
- B <- lists:seq(1, N),
- C <- lists:seq(1, N),
- A + B + C =< N,
- A*A + B*B == C*C
- ].
- ## from the Erlang console...
- c(foo).
- foo:pythag(30).
Add Comment
Please, Sign In to add comment