Last active
December 2, 2020 22:18
-
-
Save varokas/521d6b3f9006e399d511254d394d11a4 to your computer and use it in GitHub Desktop.
Revisions
-
varokas revised this gist
Dec 2, 2020 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,8 +4,10 @@ digits x | x < 10 = [x] | otherwise = digits(x `div` 10) ++ [x `mod` 10] -- x to the 4th power4 x = x^4 -- What is asked [ x | x <- [0..9999], sum(map power4 (digits x)) == x ] => [0,1,1634,8208,9474] -
varokas revised this gist
Dec 2, 2020 . No changes.There are no files selected for viewing
-
varokas created this gist
Dec 2, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,11 @@ -- Decompose Int to arrays of digits digits :: Integral a => a -> [a] digits x | x < 10 = [x] | otherwise = digits(x `div` 10) ++ [x `mod` 10] power4 x = x^4 [ x | x <- [0..9999], sum(map power4 (digits x)) == x ] => [0,1,1634,8208,9474]