OFFSET
1,4
COMMENTS
LINKS
T. D. Noe, Table of n, a(n) for n=1..1000
FORMULA
When n is prime, a(n) = 2*pi(n) - 3. When n is composite, a(n) = 2*pi(n) - 2. pi(n) is the prime counting function A000720.
EXAMPLE
a(6) = 4 because there are 4 transitions: 1 to 2, 3 to 4, 4 to 5 and 5 to 6.
MATHEMATICA
For[lst={0}; trans=0; n=2, n<100, n++, If[PrimeQ[n]!=PrimeQ[n-1], trans++ ]; AppendTo[lst, trans]]; lst
(* Second program: *)
pts[n_]:=Module[{c=2PrimePi[n]}, If[PrimeQ[n], c-3, c-2]]; Join[{0, 1}, Array[ pts, 80, 3]] (* Harvey P. Dale, Nov 12 2011 *)
Accumulate[If[Sort[PrimeQ[#]]=={False, True}, 1, 0]&/@Partition[ Range[ 0, 80], 2, 1]] (* Harvey P. Dale, May 06 2013 *)
PROG
(Haskell)
a069754 1 = 0
a069754 2 = 1
a069754 n = 2 * a000720 n - 2 - (toInteger $ a010051 $ toInteger n)
-- Reinhard Zumkeller, Dec 04 2012
CROSSREFS
KEYWORD
easy,nice,nonn
AUTHOR
T. D. Noe, May 02 2002
STATUS
approved