Guest User

Untitled

a guest
Aug 16th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. ## foo.erl
  2. -module(foo).
  3. -export([pythag/1]).
  4. pythag(N) -> lists:usort(pythag_list(N)).
  5. pythag_list(N) ->
  6. [ lists:usort([A, B, C]) ||
  7. A <- lists:seq(1, N),
  8. B <- lists:seq(1, N),
  9. C <- lists:seq(1, N),
  10. A + B + C =< N,
  11. A*A + B*B == C*C
  12. ].
  13. ## from the Erlang console...
  14. c(foo).
  15. foo:pythag(30).
Add Comment
Please, Sign In to add comment