How to resolve the algorithm Roman numerals/Encode step by step in the LotusScript programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Roman numerals/Encode step by step in the LotusScript programming language
Table of Contents
Problem Statement
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:
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Roman numerals/Encode step by step in the LotusScript programming language
Source code in the lotusscript programming language
Function toRoman(value) As String
Dim arabic(12) As Integer
Dim roman(12) As String
arabic(0) = 1000
arabic(1) = 900
arabic(2) = 500
arabic(3) = 400
arabic(4) = 100
arabic(5) = 90
arabic(6) = 50
arabic(7) = 40
arabic(8) = 10
arabic(9) = 9
arabic(10) = 5
arabic(11) = 4
arabic(12) = 1
roman(0) = "M"
roman(1) = "CM"
roman(2) = "D"
roman(3) = "CD"
roman(4) = "C"
roman(5) = "XC"
roman(6) = "L"
roman(7) = "XL"
roman(8) = "X"
roman(9) = "IX"
roman(10) = "V"
roman(11) = "IV"
roman(12) = "I"
Dim i As Integer, result As String
For i = 0 To 12
Do While value >= arabic(i)
result = result + roman(i)
value = value - arabic(i)
Loop
Next i
toRoman = result
End Function
You may also check:How to resolve the algorithm Priority queue step by step in the C# programming language
You may also check:How to resolve the algorithm Brace expansion step by step in the Visual Basic .NET programming language
You may also check:How to resolve the algorithm Rot-13 step by step in the Mirah programming language
You may also check:How to resolve the algorithm Hex words step by step in the J programming language
You may also check:How to resolve the algorithm 9 billion names of God the integer step by step in the Picat programming language