Permalink
Browse files

feat(XVI): calcaulte roman for 16

  • Loading branch information...
antonydenyer committed Nov 16, 2017
1 parent 403e186 commit da5e6a7b6ef75dcd6eb718596abcdcaf3234993c
Showing with 9 additions and 4 deletions.
  1. +4 −4 lib/roman.ex
  2. +5 −0 test/roman_test.exs
@@ -1,5 +1,9 @@
defmodule Roman do

def to_roman(number, roman_accumulator) when number >= 5 do
to_roman(number - 5, roman_accumulator <> "V")
end

def to_roman(number, roman_accumulator) when number >= 4 do
to_roman(number - 4, roman_accumulator <> "IV")
end
@@ -16,10 +20,6 @@ defmodule Roman do
to_roman(number - 9, "IX")
end

def to_roman(number) when number >= 5 do
to_roman(number - 5, "V")
end

def to_roman(number) do
to_roman(number, "")
end
@@ -36,4 +36,9 @@ defmodule RomanTest do
test "forteen is XIV" do
assert Roman.to_roman(14) == "XIV"
end

test "sixteen is XVI" do
assert Roman.to_roman(16) == "XVI"
end

end

0 comments on commit da5e6a7

Please sign in to comment.