Created
February 10, 2016 17:24
-
-
Save sammylupt/5ea2ce46fc58b6e88ae8 to your computer and use it in GitHub Desktop.
This file contains 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 characters
defmodule HappyNumberFinder do | |
def get_sum(number) do | |
number | |
|> Integer.digits #=> [4, 9] | |
|> Enum.map(&(&1 * &1)) #=> [16, 81] | |
|> Enum.reduce(&(&1 + &2)) #=> 97 | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment