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.

A006968 Number of letters in Roman numeral representation of n.

This page as a plain text file.
%I A006968 M0417 #72 Aug 20 2025 00:34:08
%S A006968 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,
%T A006968 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,
%U A006968 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
%N A006968 Number of letters in Roman numeral representation of n.
%C A006968 How is this sequence defined for large values? - _Charles R Greathouse IV_, Feb 01 2011
%C A006968 See A078715 for a discussion on the Roman 4M-problem. - _Reinhard Zumkeller_, Apr 14 2013
%C A006968 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
%D A006968 GCHQ, The GCHQ Puzzle Book, Penguin, 2016. See page 60.
%D A006968 Netnews group rec.puzzles, Frequently Asked Questions (FAQ) file. (Science Section).
%D A006968 N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).
%H A006968 Nathaniel Johnston, <a href="/A006968/b006968.txt">Table of n, a(n) for n = 1..3999</a>
%H A006968 Rec.puzzles, <a href="http://www.rec-puzzles.org">Archive</a>
%H A006968 Gerard Schildberger, <a href="/A006968/a006968.txt">The first 3999 numbers in Roman numerals</a>
%H A006968 Eric Weisstein's World of Mathematics, <a href="https://mathworld.wolfram.com/RomanNumerals.html">Roman Numerals</a>
%H A006968 Wikipedia, <a href="http://en.wikipedia.org/wiki/Roman_numerals">Roman numerals</a>
%H A006968 <a href="/index/Lc#letters">Index entries for sequences related to number of letters in n</a>
%F A006968 A006968 = A055642 o A061493, i.e., a(n) = A055642(A061493(n)). - _M. F. Hasler_, Jan 11 2015
%p A006968 A006968 := proc(n) return length(convert(n,roman)): end: seq(A006968(n),n=1..105); # _Nathaniel Johnston_, May 18 2011
%t A006968 a[n_] := StringLength[ IntegerString[ n, "Roman"]]; Table[a[n], {n, 1, 105}] (* _Jean-François Alcover_, Dec 27 2011 *)
%o A006968 (R) nchar(paste(as.roman(1 :1024))) # _N. J. A. Sloane_, Aug 23 2009, corrected by _M. F. Hasler_, Aug 18 2025
%o A006968 (Haskell)
%o A006968 a006968 = lenRom 3 where
%o A006968    lenRom 0 z = z
%o A006968    lenRom p z = [0, 1, 2, 3, 2, 1, 2, 3, 4, 2] !! m + lenRom (p - 1) z'
%o A006968                 where (z',m) = divMod z 10
%o A006968 -- _Reinhard Zumkeller_, Apr 14 2013
%o A006968 (PARI) A006968(n)=#Str(A061493(n)) \\ _M. F. Hasler_, Jan 11 2015
%o A006968 (Python)
%o A006968 def f(s, k):
%o A006968     return s[:2] if k==4 else (s[1]*(k>=5)+s[0]*(k%5) if k<9 else s[0]+s[2])
%o A006968 def a(n):
%o A006968     m, c, x, i = n//1000, (n%1000)//100, (n%100)//10, n%10
%o A006968     return len("M"*m + f("CDM", c) + f("XLC", x) + f("IVX", i))
%o A006968 print([a(n) for n in range(1, 101)]) # _Michael S. Branicky_, Mar 03 2024
%o A006968 (Python)
%o A006968 import roman
%o A006968 def A006968(n): return len(roman.toRoman(n)) # _M. F. Hasler_, Aug 18 2025
%Y A006968 Cf. A002963, A036746, A036786, A036787, A036788, A061493, A092196, A160676, A160677, A199921.
%K A006968 nonn,base,nice,easy
%O A006968 1,2
%A A006968 _N. J. A. Sloane_
%E A006968 More terms from _Eric W. Weisstein_