All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars
 perplexus dot info

 Roman Resolve (Posted on 2013-05-08)
All the roman numerals are written down in ascending order, without commas or spaces, as follows:
`IIIIIIIVVVIVIIVIIIIXXXIXII…….`
What are the respective 2013th letter and the 10000th letter in the above sequence?

Note: Each of M, D, C and L also qualifies as a roman numeral. For example, the number 1782 would be denoted MDCCLXXXII in Roman numerals.

 No Solution Yet Submitted by K Sengupta No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
 computer solution | Comment 1 of 2

n = 1: lenct = 1
DO
n = n + 1
q = n \ 1000: r = n MOD 1000
r\$ = STRING\$(q, "M")
n2 = r
q = n2 \ 100: r = n2 MOD 100
SELECT CASE q
CASE 9: r\$ = r\$ + "CM"
CASE 5 TO 8: r\$ = r\$ + "D" + STRING\$(q - 5, "C")
CASE 4: r\$ = r\$ + "CD"
CASE 0 TO 3: r\$ = r\$ + STRING\$(q, "C")
END SELECT
n2 = r
q = n2 \ 10: r = n2 MOD 10
SELECT CASE q
CASE 9: r\$ = r\$ + "XC"
CASE 5 TO 8: r\$ = r\$ + "L" + STRING\$(q - 5, "X")
CASE 4: r\$ = r\$ + "XL"
CASE 0 TO 3: r\$ = r\$ + STRING\$(q, "X")
END SELECT
n2 = r
q = n2
SELECT CASE q
CASE 9: r\$ = r\$ + "IX"
CASE 5 TO 8: r\$ = r\$ + "V" + STRING\$(q - 5, "I")
CASE 4: r\$ = r\$ + "IV"
CASE 0 TO 3: r\$ = r\$ + STRING\$(q, "I")
END SELECT
newlen = lenct + LEN(r\$)
IF lenct < 10 AND newlen >= 10 THEN
PRINT n, r\$, 10 - lenct, MID\$(r\$, 10 - lenct, 1), "10"
END IF
IF lenct < 2013 AND newlen >= 2013 THEN
PRINT n, r\$, 2013 - lenct, MID\$(r\$, 2013 - lenct, 1), "2013"
END IF
IF lenct < 10000 AND newlen >= 10000 THEN
PRINT n, r\$, 10000 - lenct, MID\$(r\$, 10000 - lenct, 1), "10,000"
END
END IF
lenct = lenct + LEN(r\$)
LOOP

(with much of the code borrowed from the solution to Roman Trivia)

finds

`6            VI             1            V             10376          CCCLXXVI       8            I             20131618         MDCXVIII       4            X             10,000`

with the first line being just a sanity check, that the 10th position in the string is the V that's the 1st letter of VI, the roman numeral for 6.

The 2013th letter is I, the 8th character of CCCLXXVI, the roman numeral for 376.

The 10,000th letter is X, the 4th character of MDCXVIII, the roman numeral for 1618.

 Posted by Charlie on 2013-05-08 12:50:21

 Search: Search body:
Forums (0)