diff --git a/roman/roman.go b/roman/roman.go index cdbf82c..efd2df7 100644 --- a/roman/roman.go +++ b/roman/roman.go @@ -6,6 +6,12 @@ func ConvertToRoman(arabic int) string { var converted strings.Builder for arabic > 0 { switch { + case arabic > 9: + converted.WriteString("X") + arabic -= 10 + case arabic > 8: + converted.WriteString("IX") + arabic -= 9 case arabic > 4: converted.WriteString("V") arabic -= 5 diff --git a/roman/roman_test.go b/roman/roman_test.go index 0d8a4b9..867144c 100644 --- a/roman/roman_test.go +++ b/roman/roman_test.go @@ -13,6 +13,9 @@ func TestRomanNemerals(t *testing.T) { {"3 gets converted to III", 3, "III"}, {"4 gets converted to IV", 4, "IV"}, {"5 gets converted to V", 5, "V"}, + {"7 gets converted to VII", 7, "VII"}, + {"9 gets converted to IX", 9, "IX"}, + {"10 gets converted to X", 10, "X"}, } for _, test := range cases { t.Run(test.Description, func(t *testing.T) {