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.

A093796 Sequence of digit-values after concatenating the natural numbers < 4000 in Roman numeral representation.

Original entry on oeis.org

1, 1, 1, 1, 1, 1, 1, 5, 5, 5, 1, 5, 1, 1, 5, 1, 1, 1, 1, 10, 10, 10, 1, 10, 1, 1, 10, 1, 1, 1, 10, 1, 5, 10, 5, 10, 5, 1, 10, 5, 1, 1, 10, 5, 1, 1, 1, 10, 1, 10, 10, 10, 10, 10, 1, 10, 10, 1, 1, 10, 10, 1, 1, 1, 10, 10, 1, 5, 10, 10, 5, 10, 10, 5, 1, 10, 10, 5, 1
Offset: 1

Views

Author

Reinhard Zumkeller, May 18 2004

Keywords

Comments

In other words, read the sequence of Roman numerals of natural numbers without spaces: I II III IV V VI VII VIII IX, ..., replacing I by 1, V by 5, X by 10, etc.

Examples

			I,II,III,IV,V,VI,VII,VIII,IX,X,XI,XII, ...
I,(I,I),(I,I,I),(I,V),V,(V,I),(V,I,I),(V,I,I,I),(I,X), ...
1,(1,1),(1,1,1),(1,5),5,(5,1),(5,1,1),(5,1,1,1),(1,10), ...
1,1,1,1,1,1,1,5,5,5,1,5,1,1,5,1,1,1,1,10,10,10,1,10,1,1, ...
		

References

  • GCHQ, The GCHQ Puzzle Book, Penguin, 2016. See Question 300(b), page 199.

Crossrefs

Cf. A007376.
Cf. A061493; A222581 (run lengths).

Programs

  • Haskell
    import Data.List (unfoldr)
    a093796 n = a093796_list !! n
    a093796_list = concatMap (reverse . unfoldr r) $ map a061493 [1..3999]
       where r 0 = Nothing
             r x = Just ([0,1,5,10,50,100,500,1000] !! fromInteger d, x')
                   where (x', d) = divMod x 10
    -- Reinhard Zumkeller, Apr 14 2013
    
  • Maple
    for n from 1 to 50 do r:=convert(n, roman): for j from 1 to length(r) do printf("%d, ", convert(r[j],arabic)): od: od: # Nathaniel Johnston, May 18 2011
  • Mathematica
    A093796full = Flatten[FromRomanNumeral[Characters[RomanNumeral[Range[3999]]]]];
    A093796full[[;;100]] (* Paolo Xausa, Mar 03 2024 *)
  • 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 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():
        v = {"I":1, "V":5, "X":10, "L":50, "C":100, "D":500, "M":1000}
        ans = []
        for i in range(1, 4000): ans.extend([v[d] for d in r(i)])
        return ans
    print(afull()[:80]) # Michael S. Branicky, Mar 04 2024