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.

A246398 Smallest number of digits that have to be inserted into or prepended to decimal representation of n, to get a prime.

Original entry on oeis.org

2, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 2, 1, 0, 0, 1, 1, 1, 1, 1, 0, 1, 0, 2, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 2, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 2, 1
Offset: 0

Views

Author

Reinhard Zumkeller, Nov 13 2014

Keywords

Comments

a(n) = 0 iff n is a prime number, a(A000040(n)) = 0;
a(n) = A055642(A062584(n)) - A055642(n).

Crossrefs

Programs

  • Haskell
    a246398 n = a246398_list !! n
    a246398_list = f 0 $ map show a000040_list where
       f x pss = (length ps - length xs) :
                 f (x + 1) (dropWhile (== xs) pss)
         where ps = head [qs | qs <- pss, isin xs qs]; xs = show x
       isin [] _  = True
       isin _  [] = False
       isin (u:us) vs = not (null ws) && isin us ws
                        where ws = dropWhile (/= u) vs