# Encode

```ruby
func arabic2roman(num, roman='') {
    static lookup = [
        :M:1000, :CM:900, :D:500,
        :CD:400, :C:100,  :XC:90,
        :L:50,   :XL:40,  :X:10,
        :IX:9,   :V:5,    :IV:4,
        :I:1
    ]
    lookup.each { |pair|
        while (num >= pair.second) {
            roman += pair.first
            num -= pair.second
        }
    }
    return roman
}
say("1990 in roman is " + arabic2roman(1990))
say("2008 in roman is " + arabic2roman(2008))
say("1666 in roman is " + arabic2roman(1666))
```

#### Output:

```
1990 in roman is MCMXC
2008 in roman is MMVIII
1666 in roman is MDCLXVI
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://trizen.gitbook.io/sidef-lang/programming_tasks/r/roman-numerals/encode.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
