login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A066246
a(n) = 0 unless n is a composite number A002808(k) then a(n) = k.
16
0, 0, 0, 1, 0, 2, 0, 3, 4, 5, 0, 6, 0, 7, 8, 9, 0, 10, 0, 11, 12, 13, 0, 14, 15, 16, 17, 18, 0, 19, 0, 20, 21, 22, 23, 24, 0, 25, 26, 27, 0, 28, 0, 29, 30, 31, 0, 32, 33, 34, 35, 36, 0, 37, 38, 39, 40, 41, 0, 42, 0, 43, 44, 45, 46, 47, 0, 48, 49, 50, 0, 51, 0, 52, 53, 54, 55, 56, 0, 57
OFFSET
1,6
LINKS
Charles R Greathouse IV, Table of n, a(n) for n = 1..10000
FORMULA
a(n) = A239968(n) + A010051(n) - 1. - Reinhard Zumkeller, Mar 30 2014
MATHEMATICA
Module[{k=1}, Table[If[CompositeQ[n], k; k++, 0], {n, 100}]] (* Requires Mathematica version 10 or later *) (* Harvey P. Dale, Jan 03 2019 *)
PROG
(PARI) a(n)=if(isprime(n), 0, max(0, n-primepi(n)-1)) \\ Charles R Greathouse IV, Aug 21 2011
(Haskell)
import Data.List (unfoldr, genericIndex)
a066246 n = genericIndex a066246_list (n - 1)
a066246_list = unfoldr x (1, 1, a002808_list) where
x (i, z, cs'@(c:cs)) | i == c = Just (z, (i + 1, z + 1, cs))
| i /= c = Just (0, (i + 1, z, cs'))
-- Reinhard Zumkeller, Jan 29 2014
CROSSREFS
KEYWORD
nonn
AUTHOR
Reinhard Zumkeller, Dec 09 2001
STATUS
approved