Created
June 30, 2013 16:06
-
-
Save stefanroex/5895757 to your computer and use it in GitHub Desktop.
Cocos
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 Cocos do | |
def test_amount x do | |
if check_division x, 7 do | |
x | |
else | |
test_amount x + 1 | |
end | |
end | |
defp check_division _, 0 do | |
true | |
end | |
defp check_division n, m do | |
if rem(n, 7) == 1 do | |
check_division div(n, 7), m - 1 | |
end | |
end | |
end | |
IO.puts Cocos.test_amount(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment