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-10 of 16 results. Next

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

A061493 Roman numerals written using 1 for I, 2 for V, 3 for X, 4 for L, 5 for C, 6 for D, 7 for M.

Original entry on oeis.org

1, 11, 111, 12, 2, 21, 211, 2111, 13, 3, 31, 311, 3111, 312, 32, 321, 3211, 32111, 313, 33, 331, 3311, 33111, 3312, 332, 3321, 33211, 332111, 3313, 333, 3331, 33311, 333111, 33312, 3332, 33321, 333211, 3332111, 33313, 34, 341, 3411, 34111, 3412
Offset: 1

Views

Author

Frank Ellermann, Jun 12 2001

Keywords

Comments

From Daniel Forgues, Jan 16 2015: (Start)
The Romans in the era of the Roman Empire did not have 0 as a number.
The initial "N" (nulla, meaning "none", or nihil, meaning "nothing") was used as a zero symbol in a table of Roman numerals by Bede or his colleague around 725, but even in the Middle Ages it never became a standard. (End) [Corrected by M. F. Hasler and Peter Luschny, Aug 16 2025]
3999 (MMMCMXCIX) is the largest decimal number that has a well-defined Roman numeral representation. Therefore the sequence deliberately stops there to avoid the ambiguous representations of larger numbers. - Jamie Robert Creasey, May 01 2021
The use of 'N' to indicate 0 or "none" long survived in the historic apothecaries' system of measurement, well into the 20th century, to designate quantities in pharmaceutical prescriptions. - M. F. Hasler, Aug 16 2025

Examples

			a(14) = 312 because 14 = XIV in Roman, and I,V,X are coded as 1,2,3 respectively.
a(66) = 4321, LXVI is 50+10+5+1 = 66, a(44) = 3412, XLIV is -10+50-1+5 = 44
		

Crossrefs

Programs

  • Haskell
    a061493 n = read $ r 1 [] n :: Integer where
      r _ roms 0 = roms
      r p roms z = case p of
        1 -> r 2 (d '1' '2' '3' m) z'
        2 -> r 3 (d '3' '4' '5' m ++ roms) z'
        3 -> r 4 (d '5' '6' '7' m ++ roms) z'
        4 -> replicate z '7' ++ roms
        where (z',m) = divMod z 10
      d i j k c =
        [[],[i],[i,i],[i,i,i],[i,j],[j],[j,i],[j,i,i],[j,i,i,i],[i,k]] !! c
    -- Reinhard Zumkeller, Apr 14 2013
    
  • Mathematica
    Array[FromDigits[Characters@ RomanNumeral[#] /. {"I" -> 1, "V" -> 2, "X" -> 3, "L" -> 4, "C" -> 5, "D" -> 6, "M" -> 7}] &, 44] (* Michael De Vlieger, May 01 2021 *)
  • PARI
    {A061493(n,s="",c=[1000,7,900,57,500,6,400,56,100,5,90,35,50,4,40,34,10,3,9,13,5,2,4,12,1,1])= forstep(i=1,#c,2,while(n>=c[i],n-=c[i];s=Str(s,c[i+1])));eval(s)} \\ 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 int("7"*m + f("567", c) + f("345", x) + f("123", i))
    print([a(n) for n in range(1, 45)]) # Michael S. Branicky, Aug 24 2022
    
  • Python
    import roman
    def A061493(n, d={ord(c):str(i) for i,c in enumerate("NIVXLCDM")}):
        return int(roman.toRoman(n).translate(d)) # M. F. Hasler, Aug 16 2025

Formula

a(n)=i <=> A003587(i)=n, for i in {1,...,7}, i.e., A061493 is a left inverse of A003587 on {1,...,7}. - M. F. Hasler, Jan 12 2015

Extensions

0 removed again by Georg Fischer, Jan 20 2019

A163828 Number of straight line segments in all letters of the capitalized English name of n.

Original entry on oeis.org

9, 7, 6, 15, 5, 10, 3, 13, 12, 11, 9, 19, 18, 21, 18, 20, 16, 26, 23, 24, 18, 25, 24, 33, 23, 28, 21, 31, 30, 29, 13, 20, 19, 28, 18, 23, 16, 26, 25, 24, 10, 17, 16, 25, 15, 20, 13, 23, 22, 21, 12, 19, 18, 27, 17, 22, 15, 25, 24, 23, 8, 15, 14, 23, 13, 18, 11, 21, 20, 19, 18
Offset: 0

Views

Author

Jonathan Vos Post, Aug 05 2009

Keywords

Comments

Number of straight line segments (chisel strokes) in the capitalized English name of n (excluding spaces and hyphens), counting smooth curves as zero strokes.
The 15 letters which are entirely strokes (no curves): A(3), E(4), F(3), H(3), I(1), K(3), L(2), M(4), N(3), T(2), V(2), W(4), X(2), Y(3), Z(3).
Those 4 which are entirely curves (and count as zero): C, O, S, U.
Those 7 which mix strokes and curves: B(1), D(1), G(2), J(1), P(1), Q(1), R(2).
a(16)=16 is a fixed point.
The numbers written entirely from stroke-only letters are A163670.

Examples

			a(0) = 9 because ZERO has (letter by letter) 3+4+2+0 = 9 straight line segments (chisel strokes).
a(1) = 7 because ONE has 0+3+4 = 7 strokes.
a(20) = 18 because TWENTY (all strokes) has 2+4+4+3+2+3 = 18 strokes.
		

Crossrefs

Programs

  • Maple
    names :=["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine",
    "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen",
    "nineteen", "twenty", "twentyone", "twentytwo", "twentythree", "twentyfour", "twentyfive", "twentysix",
    "twentyseven", "twentyeight", "twentynine", "thirty", "thirtyone", "thirtytwo", "thirtythree",
    "thirtyfour", "thirtyfive", "thirtysix", "thirtyseven", "thirtyeight", "thirtynine", "forty",
    "fortyone", "fortytwo", "fortythree", "fortyfour", "fortyfive", "fortysix", "fortyseven",
    "fortyeight", "fortynine", "fifty", "fiftyone", "fiftytwo", "fiftythree", "fiftyfour",
    "fiftyfive", "fiftysix", "fiftyseven", "fiftyeight", "fiftynine", "sixty", "sixtyone",
    "sixtytwo", "sixtythree", "sixtyfour", "sixtyfive", "sixtysix", "sixtyseven", "sixtyeight",
    "sixtynine", "seventy", "seventyone", "seventytwo", "seventythree", "seventyfour",
    "seventyfive", "seventysix", "seventyseven", "seventyeight", "seventynine", "eighty",
    "eightyone", "eightytwo", "eightythree", "eightyfour", "eightyfive", "eightysix",
    "eightyseven", "eightyeight", "eightynine", "ninety", "ninetyone", "ninetytwo",
    "ninetythree", "ninetyfour", "ninetyfive", "ninetysix", "ninetyseven", "ninetyeight",
    "ninetynine", "onehundred"] :
    cstrok := [ 3, 1, 0, 1, 4, 3, 2, 3, 1, 1, 3, 2, 4, 3, 0, 1, 1, 2, 0, 2, 0, 2, 4, 2, 3, 3 ] ;
    A163828 := proc(n) global names, cstrok; a := 0 ; for c in StringTools[Explode]( names[n+1]) do a := a+ cstrok[StringTools[Ord](c)-96] ; od: a ; end:
    seq(A163828(n),n=0..70) ; # R. J. Mathar, Sep 29 2009

Extensions

a(36) changed to 16 by R. J. Mathar, Sep 29 2009

A093783 Sum of digits of n in Roman numeral representation.

Original entry on oeis.org

1, 2, 3, 6, 5, 6, 7, 8, 11, 10, 11, 12, 13, 16, 15, 16, 17, 18, 21, 20, 21, 22, 23, 26, 25, 26, 27, 28, 31, 30, 31, 32, 33, 36, 35, 36, 37, 38, 41, 60, 61, 62, 63, 66, 65, 66, 67, 68, 71, 50, 51, 52, 53, 56, 55, 56, 57, 58, 61, 60, 61, 62, 63, 66, 65, 66, 67, 68
Offset: 1

Views

Author

Reinhard Zumkeller, May 17 2004

Keywords

Examples

			n=42 == XLII: a(42) = 'X' + 'L' + 'I' + 'I' = 10+50+1+1 = 62.
		

Crossrefs

Programs

  • Haskell
    a093783 n = q 0 $ a061493 n where
         q s 0 = s
         q s x = q (s + [0,1,5,10,50,100,500,1000] !! d') x'
                 where  (x',d) = divMod x 10; d' = fromInteger d
    -- Reinhard Zumkeller, Apr 14 2013
    (HP 49G calculator)
    ::
      CK1&Dispatch
      # FF
      ::
        FPTR2 ^DupQIsZero?
        caseSIZEERR
        FPTR2 ^Z>S
        Z0_
        SWAP
        DUPLEN$
        ZERO_DO
        DUP
        ISTOP-INDEX
        SUB$1#
        BINT48
        #-
        BINT4
        OVER#=
        OVER
        BINT9
        #=
        OR
        IT
        #2+
        FPTR2 ^#>Z
        Z10_
        INDEX@
        FPTR2 ^RP#
        FPTR2 ^RMULText
        ROT
        FPTR2 ^RADDext
        SWAPLOOP
        DROP
      ;
    ;
    Gerald Hillier, Sep 08 2015
  • Maple
    A093783 := proc(n) local r: r:=convert(n, roman): return add(convert(r[j], arabic), j=1..length(r)): end: seq(A093783(n), n=1..68); # Nathaniel Johnston, May 18 2011
  • Mathematica
    Total[#2 FromRomanNumeral[#1] & @@@ Tally[Characters@ RomanNumeral@ #]] & /@ Range@ 68 (* Michael De Vlieger, Sep 08 2015, Version 10.2 *)

A163670 Numbers whose English name (excluding spaces and hyphens) is written with only straight line segments (chisel strokes).

Original entry on oeis.org

5, 9, 10, 11, 12, 15, 19, 20, 25, 29, 50, 55, 59, 90, 95, 99
Offset: 1

Views

Author

Jonathan Vos Post, Aug 02 2009

Keywords

Comments

There are no elements in the sequence beyond 99 because of curves in writing hUnDReD, thOUSanD, milliOn, BilliOn, and so forth. If one counts the segments (chisel strokes) then 29 is the unique fixed point of that derived sequence.
Specifically, these are the numbers whose names use only the letters A, E, F, H, I, K, L, M, N, T, V, W, X, Y, and Z. [From Franklin T. Adams-Watters, Aug 06 2009]

Examples

			a(1) = 5 because FIVE is the smallest integer whose English name is written with only straight line segments. 6 is not in the sequence because the letter S has curves. a(2) = 9 because NINE is the next integer whose English name is written with only straight line segments.
		

Crossrefs

Extensions

Missing 55 and 95 added by Franklin T. Adams-Watters, Aug 06 2009
Slightly edited by Charles R Greathouse IV, Oct 05 2009

A002964 Smallest number requiring n chisel strokes for its representation in Roman numerals.

Original entry on oeis.org

1, 2, 3, 7, 8, 17, 18, 27, 28, 37, 38, 87, 88, 187, 188, 287, 288, 387, 388, 788, 887, 888, 1388, 1788, 1887, 1888, 2388, 2788, 2887, 2888, 3388, 3788, 3887, 3888
Offset: 1

Views

Author

Keywords

Comments

A002963(a(n)) = n. - Reinhard Zumkeller, Apr 14 2013

Crossrefs

Cf. A002963.

Programs

  • Haskell
    a002964 = (+ 1) . fromJust . (`elemIndex` (map a002963 [1..3888]))
    -- Reinhard Zumkeller, Apr 14 2013
  • Mathematica
    DeleteDuplicates[Table[{n,Total[Characters[RomanNumeral[n]]/.{"L"->2,"X"->2,"V"->2,"I"->1,"M"->4,"C"->2,"D"->3}]},{n,4000}],GreaterEqual[#1[[2]],#2[[2]]]&][[;;,1]] (* Harvey P. Dale, Jan 19 2025 *)

Extensions

More terms from Erich Friedman
For n>13: data corrected and completed up to A002963(3888)=34 by Reinhard Zumkeller, Apr 14 2013

A119310 Alphabetical value of n in its Roman numerals-based representation.

Original entry on oeis.org

9, 18, 27, 31, 22, 31, 40, 49, 33, 24, 33, 42, 51, 55, 46, 55, 64, 73, 57, 48, 57, 66, 75, 79, 70, 79, 88, 97, 81, 72, 81, 90, 99, 103, 94, 103, 112, 121, 105, 36, 45, 54, 63, 67, 58, 67, 76, 85, 69, 12, 21, 30, 39, 43, 34, 43, 52, 61, 45, 36, 45, 54, 63, 67, 58, 67, 76, 85, 69
Offset: 1

Views

Author

Tanya Khovanova, Jul 23 2006

Keywords

Comments

This uses "modern" (i.e. medieval) Roman numerals; the ancient Romans did not use prefixed letters to subtract. One sometimes sees e.g. "IL" for 49, but this is not standard; the standard representation encodes each digit separately. Sequence is finite since Roman numerals are only defined up to 3999. (There is an extension using underlined letters up to 3999999, but that's still finite.) - Franklin T. Adams-Watters, Jul 26 2006

Examples

			a(12) corresponds to XII whose alphabetical value is 24 + 9 + 9 = 42.
		

Crossrefs

Extensions

More terms from Franklin T. Adams-Watters, Jul 26 2006

A093788 The Roman numerals, with "i" replaced by "1", "v" replaced by "5", "x" replaced by 10, etc.

Original entry on oeis.org

1, 11, 111, 15, 5, 51, 511, 5111, 110, 10, 101, 1011, 10111, 1015, 105, 1051, 10511, 105111, 10110, 1010, 10101, 101011, 1010111, 101015, 10105, 101051, 1010511, 10105111, 1010110, 101010, 1010101, 10101011, 101010111, 10101015, 1010105
Offset: 1

Views

Author

William J. Rapaport (rapaport(AT)buffalo.edu), May 17 2004

Keywords

Comments

A more compact and easier to parse version is A061493, where I, V, X, L, ... are replaced by 1, 2, 3, 4, ... The terms of this sequence can be converted to those of A061493 by changing digits '5' to '2' and deleting each digit '0' upon increasing by 2 the nonzero digit to its left. - M. F. Hasler, Jul 25 2016

Crossrefs

Programs

  • PARI
    {A093788(n)=A061493(n,,[1000, 1000, 900, 1001000, 500, 500, 400, 100500, 100, 100, 90, 10100, 50, 50, 40, 1050, 10, 10, 9, 110, 5, 5, 4, 15, 1, 1])} \\ M. F. Hasler, Jul 25 2016

Extensions

Cross-references added and data double-checked by M. F. Hasler, Jul 25 2016

A118098 Numbers that require three strokes when written in Roman numerals (excluding serifs). III IV VI IX XI LI XC CII CV CX CL.

Original entry on oeis.org

3, 4, 6, 9, 11, 51, 90, 102, 105, 110, 150, 201, 300, 400, 501, 600
Offset: 1

Views

Author

Dylan Nicholson (wizofaus(AT)hotmail.com), May 11 2006

Keywords

Comments

Unlike the case in A002963, C is counted as one stroke and D is counted as two strokes here. This sequence is complete up to 3999, though it may contain some more terms such as 5000 depending on the convention used to represent larger numbers. - Nathaniel Johnston, May 18 2011

Formula

Numbers that require three strokes when written in Roman numerals (excluding serifs).

Extensions

a(12)-a(16) from Nathaniel Johnston, May 18 2011

A341737 a(n) is the number of segments necessary to represent n in the Cistercian numeral system.

Original entry on oeis.org

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

Views

Author

Stefano Spezia, Feb 18 2021

Keywords

Comments

The sequence is finite because the numeral system of Cistercian monks allows us to represent the numbers from 0 to 9999.

Crossrefs

Programs

  • Mathematica
    SN:={"0"->1,"1"->2,"2"->2,"3"->2,"4"->2,"5"->3,"6"->2,"7"->3,"8"->3,"9"->4}; OI:={11,15,17,19,22,28,29,51,55,57,59,71,75,77,79,82,88,89,91,92,95,97,98,99}; Table[(Characters[IntegerString[Floor[n/100]]]/. SN//Total)-Length[Characters[IntegerString[Floor[n/100]]]]+1-If[MemberQ[OI,Floor[n/100]],1,0]-Boole[Floor[n/100]==99]+(Characters[IntegerString[Mod[n,100]]]/. SN//Total)-Length[Characters[IntegerString[Mod[n,100]]]]+1-If[MemberQ[OI,Mod[n,100]],1,0]-Boole[Mod[n,100]==99]-1,{n,0,9999}]
    (* Function for visualizing a Cistercian numeral *)
    CistercianNumeral[n_]:=ResourceFunction["CistercianNumberEncode"][n];

Formula

a(n) <= 9.
Showing 1-10 of 16 results. Next