Task

Create a function taking a positive integer as its parameter and returning a string containing the Roman numeral representation of that integer. Modern Roman numerals are written by expressing each digit separately, starting with the left most digit and skipping any digit with a value of zero.



In Roman numerals:

 1990 is rendered: 1000=M, 900=CM, 90=XC; resulting in MCMXC
 2008 is written as 2000=MM, 8=VIII; or MMVIII
 1666 uses each Roman symbol in descending order: MDCLXVI


#lang racket
(define (encode/roman number)
  (cond ((>= number 1000) (string-append "M" (encode/roman (- number 1000))))
        ((>= number 900) (string-append "CM" (encode/roman (- number 900))))
        ((>= number 500) (string-append "D" (encode/roman (- number 500))))
        ((>= number 400) (string-append "CD" (encode/roman (- number 400))))
        ((>= number 100) (string-append "C" (encode/roman (- number 100))))
        ((>= number 90) (string-append "XC" (encode/roman (- number 90))))
        ((>= number 50) (string-append "L" (encode/roman (- number 50))))
        ((>= number 40) (string-append "XL" (encode/roman (- number 40))))
        ((>= number 10) (string-append "X" (encode/roman (- number 10))))
        ((>= number 9) (string-append "IX" (encode/roman (- number 9))))
        ((>= number 5) (string-append "V" (encode/roman (- number 5))))
        ((>= number 4) (string-append "IV" (encode/roman (- number 4))))
        ((>= number 1) (string-append "I" (encode/roman (- number 1))))
        (else "")))