cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

Showing 1-6 of 6 results.

A006968 Number of letters in Roman numeral representation of n.

Original entry on oeis.org

1, 2, 3, 2, 1, 2, 3, 4, 2, 1, 2, 3, 4, 3, 2, 3, 4, 5, 3, 2, 3, 4, 5, 4, 3, 4, 5, 6, 4, 3, 4, 5, 6, 5, 4, 5, 6, 7, 5, 2, 3, 4, 5, 4, 3, 4, 5, 6, 4, 1, 2, 3, 4, 3, 2, 3, 4, 5, 3, 2, 3, 4, 5, 4, 3, 4, 5, 6, 4, 3, 4, 5, 6, 5, 4, 5, 6, 7, 5, 4, 5, 6, 7, 6, 5, 6, 7, 8, 6, 2, 3, 4, 5, 4, 3, 4, 5, 6, 4, 1, 2, 3, 4, 3, 2
Offset: 1

Views

Author

Keywords

Comments

How is this sequence defined for large values? - Charles R Greathouse IV, Feb 01 2011
See A078715 for a discussion on the Roman 4M-problem. - Reinhard Zumkeller, Apr 14 2013
The sequence can be considered to be defined via the formula (as A055642 o A061493), so the question is to be posed in A061493, not here. - M. F. Hasler, Jan 12 2015

References

  • GCHQ, The GCHQ Puzzle Book, Penguin, 2016. See page 60.
  • Netnews group rec.puzzles, Frequently Asked Questions (FAQ) file. (Science Section).
  • N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).

Crossrefs

Programs

  • Haskell
    a006968 = lenRom 3 where
       lenRom 0 z = z
       lenRom p z = [0, 1, 2, 3, 2, 1, 2, 3, 4, 2] !! m + lenRom (p - 1) z'
                    where (z',m) = divMod z 10
    -- Reinhard Zumkeller, Apr 14 2013
    
  • Maple
    A006968 := proc(n) return length(convert(n,roman)): end: seq(A006968(n),n=1..105); # Nathaniel Johnston, May 18 2011
  • Mathematica
    a[n_] := StringLength[ IntegerString[ n, "Roman"]]; Table[a[n], {n, 1, 105}] (* Jean-François Alcover, Dec 27 2011 *)
  • PARI
    A006968(n)=#Str(A061493(n)) \\ M. F. Hasler, Jan 11 2015
    
  • Python
    def f(s, k):
        return s[:2] if k==4 else (s[1]*(k>=5)+s[0]*(k%5) if k<9 else s[0]+s[2])
    def a(n):
        m, c, x, i = n//1000, (n%1000)//100, (n%100)//10, n%10
        return len("M"*m + f("CDM", c) + f("XLC", x) + f("IVX", i))
    print([a(n) for n in range(1, 101)]) # Michael S. Branicky, Mar 03 2024
    
  • Python
    import roman
    def A006968(n): return len(roman.toRoman(n)) # M. F. Hasler, Aug 18 2025
  • R
    nchar(paste(as.roman(1 :1024))) # N. J. A. Sloane, Aug 23 2009, corrected by M. F. Hasler, Aug 18 2025
    

Formula

A006968 = A055642 o A061493, i.e., a(n) = A055642(A061493(n)). - M. F. Hasler, Jan 11 2015

Extensions

More terms from Eric W. Weisstein

A093703 Numbers whose Roman numeral representation, reversed, is a Roman numeral.

Original entry on oeis.org

1, 2, 3, 4, 5, 6, 9, 10, 11, 19, 20, 30, 40, 50, 60, 90, 100, 110, 190, 200, 300, 400, 500, 600, 900, 1000, 1100, 1900, 2000, 3000
Offset: 1

Views

Author

Reinhard Zumkeller, May 17 2004

Keywords

Comments

A subset of this is A078715, palindromic Roman numerals. These are not "old style" Roman numerals (where 4 = IIII).
The sequence contains only values less than 4000, see A078715 for a discussion of the Roman 4M-problem.

Examples

			a(1) = 1 because Roman(1) = I and Reversal(I) = I, which is Roman.
a(4) = 4 because Roman(4) = IV and Reversal(IV) = VI, which is Roman.
a(10) = 19 because Roman(19) = XIX which is a palindromic Roman numeral.
a(27) = 900 because Roman(900) = CM and Reversal(CM) = MC, which is Roman.
40 == XL -> LX == 60, therefore 40 and 60 are terms.
1999 is not in the sequence because "MIM" is not a well-formed Roman numeral for 1999, although it looks like one; see Schildberger.
		

Crossrefs

Cf. A078715 (palindromic Roman numerals), A061493.

Programs

  • Haskell
    a093703 n = a093703_list !! (n-1)
    a093703_list = filter
       ((`elem` map a061493 [1..3999]) . a004086 . a061493) [1..]
    -- Reinhard Zumkeller, Apr 14 2013
  • Mathematica
    Select[Range[3000], RomanNumeral[FromRomanNumeral[#]] == # & [StringReverse[RomanNumeral[#]]] &] (* Paolo Xausa, Mar 03 2024 *)

Extensions

Added sections of text from the erroneous A123054. - N. J. A. Sloane, Apr 15 2013

A222581 Run lengths of digits when concatenating Roman numerals less than 4000, cf. A093796.

Original entry on oeis.org

7, 3, 1, 1, 2, 1, 4, 3, 1, 1, 2, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 3, 1, 1, 5, 1, 2, 2, 2, 3, 2, 1, 1, 2, 1, 2, 1, 1, 2, 1, 2, 2, 1, 3, 2, 1, 7, 1, 3, 2, 3, 3, 3, 1, 1, 3, 1, 3, 1, 1, 3, 1, 2, 3, 1, 3, 3, 1, 2, 1, 1, 1, 1, 1, 1, 2, 1, 1, 3, 1, 1
Offset: 1

Views

Author

Reinhard Zumkeller, Apr 14 2013

Keywords

Comments

See A078715 for a discussion on the Roman 4M-problem;
a(n) <= 7, that is, the longest run of consecutive equal digits in A093796 has length = 7; see also example.

Examples

			The 3999 Roman numerals of all numbers less than 4000 consist of 30000 digits; there are 19770 runs of consecutive equal digits: a(19770) = 1 is the last term of this sequence;
a(1)=a(52)=7, there are two runs with length 7: the first is "IIIIIII" which is the prefix of the concatenation of I, II, III and IV, the second is "XXXXXXX" which is contained in the concatenation of XXIX, XXX and XXXI;
a(1022)=a(14573)=6, there are also two runs with length 6: the first is "CCCCCC" which is a prefix of the concatenation of CCC and CCCI, the second is "MMMMMM" which is a prefix of the concatenation of MMM and MMMI;
a(30)=5, there is just one run with length 5: "XXXXX" which is contained in the concatenation of XIX, XX and XXI;
a(7)=a(644)=a(1359)=a(9375)=a(19194)=4, there are five runs with length 4: "IIII", two times "CCCC" and "MMMM", they occur in concatenations of (VIII, IX), (CC, CCI), (CCCXC, CCCXCI), (MM, MMI), (MMMCM, MMMCMI), respectively.
		

Crossrefs

Cf. A006968.

Programs

  • Haskell
    import Data.List (group)
    a222581 n = a222581_list !! (n-1)
    a222581_list = map length $ group a093796_list
    
  • Mathematica
    A222581full = Map[Length, Split[Flatten[FromRomanNumeral[Characters[RomanNumeral[ Range[3999]]]]]]]; A222581full[[;;100]] (* Paolo Xausa, Mar 03 2024 *)
  • Python
    from itertools import groupby
    def f(s, k):
        return s[:2] if k==4 else (s[1]*(k>=5)+s[0]*(k%5) if k<9 else s[0]+s[2])
    def r(n):
        m, c, x, i = n//1000, (n%1000)//100, (n%100)//10, n%10
        return "M"*m + f("CDM", c) + f("XLC", x) + f("IVX", i)
    def afull():
        return [len(list(g)) for k, g in groupby("".join(r(i) for i in range(1, 4000)))]
    print(afull()[:90]) # Michael S. Branicky, Mar 03 2024

A082763 Roman numeral contains an asymmetric symbol (L).

Original entry on oeis.org

40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152
Offset: 1

Views

Author

Rick L. Shepherd, May 21 2003

Keywords

Comments

I,V,X,C,D,M - and even the vinculum (bar) and apostrophus (backwards "C") - are each symmetric: horizontally, vertically, or both.
Numbers containing a 4 when decimally encoded with A061493. - Reinhard Zumkeller, Apr 14 2013

Examples

			40 = XL, 89 = LXXXIX, 140 = CXL.
		

Crossrefs

Cf. A006968 (Roman numerals main entry), A078715 (Palindromic Roman numerals).

Programs

  • Haskell
    a082763 n = a082763_list !! (n-1)
    a082763_list = filter (containsL . a061493) [1..3999] where
       containsL x = d == 4 || x > 0 && containsL x' where
                     (x',d) = divMod x 10
    -- Reinhard Zumkeller, Apr 14 2013
  • Maple
    with(StringTools): for n from 1 to 152 do if(Search("L", convert(n, roman)) > 0)then printf("%d, ", n): fi: od: # Nathaniel Johnston, May 18 2011
  • Mathematica
    Select[Range[200],StringCases[RomanNumeral[#],"L"]!={}&] (* Harvey P. Dale, Jun 10 2023 *)
  • PARI
    /* "%" use below is actually identical to lift(Mod(n-1,50)) */ /* (n-1)50 could be used for integer division below */ /* instead of floor, but the OEIS sometimes loses  */ /* characters depending upon where on a submitted line they are. */ a(n)=floor((n-1)/50)*100+40+(n-1)%50 for(n=1,125,print1(a(n),","))
    

Formula

a(n+50) = a(n) + 100 for n >= 1 [a(n+L) = a(n) + C for n >= I], a(1) = 40 [a(I) = XL], a(n+1) = a(n) + 1 for 1 <= n <= 49 [a(n+I) = a(n) + I for I <= n <= XLIX]; so a(n) = floor((n-1)/50)*100 + 40 + ((n-1)(mod 50)) for n >= 1 [a(n) = floor((n-I)/L)*C + XL + ((n-I)(mod L)) for n >= I].

A093785 Numbers that are divisible by every digit in their Roman numeral representation.

Original entry on oeis.org

1, 2, 3, 5, 10, 20, 30, 50, 100, 200, 300, 500, 1000, 2000, 3000
Offset: 1

Views

Author

Reinhard Zumkeller, May 17 2004

Keywords

Comments

The sequence contains only values less than 4000, see A078715 for a discussion on the Roman 4M-problem.

Examples

			I, II, III, V, X, XX, XXX, L, C, CC, CCC, D, M, MM, MMM.
		

Crossrefs

Cf. A034838.
Cf. A061493.

Programs

  • Haskell
    a093785 n = a093785_list !! (n-1)
    a093785_list = filter p [1..3999] where
       p v = q $ a061493 v where
         q w = w == 0 || v `mod` ([0,1,5,10,50,100,500,1000] !! d') == 0 && q w'
              where  (w',d) = divMod w 10; d' = fromInteger d
    -- Reinhard Zumkeller, Apr 14 2013

A215121 Strobogrammatic palindromic numbers in their Roman numeral representation.

Original entry on oeis.org

1, 2, 3, 10, 19, 20, 30
Offset: 1

Views

Author

Jonathan Vos Post, Aug 03 2012

Keywords

Comments

Numbers which, written as Roman numerals, are the same upside down and backwards.
Upside-down-invariant numbers are also called ambigrams. "Upside down" here means rotated by 180 degrees (i.e., central symmetry), NOT "vertically flipped" (symmetry w.r.t. horizontal line).
V, L, C, D, M (5, 50, 100, 500, 1000 in decimal) are not the same upside-down. Excludes "old style" Roman numeral representation of n (e.g., IIII rather than IV).

Examples

			I, II, III, X, XIX, XX, XXX.
		

Crossrefs

Showing 1-6 of 6 results.