Skip to content

Instantly share code, notes, and snippets.

@maliqq
Created September 19, 2012 01:01
Show Gist options
  • Save maliqq/3747018 to your computer and use it in GitHub Desktop.
Save maliqq/3747018 to your computer and use it in GitHub Desktop.
Euler#4
is_palindrome([]) -> true;
is_palindrome([_|_=[]]) -> true;
is_palindrome(L) when is_integer(L) -> is_palindrome(erlang:integer_to_list(L));
is_palindrome(L) -> L == lists:reverse(L).
product_palindrome(A) -> [A * B || B <- lists:seq(A + 1, 999)].
problem4() ->
L = [product_palindrome(A) || A <- lists:seq(100, 998)],
L1 = lists:filter(fun(I) -> is_palindrome(I) end, lists:flatten(L)),
io:format("~p", [lists:last(lists:sort(L1))]).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment