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”).

A073898
a(1) = 1; for n>1, a(n) = smallest even or odd number not occurring earlier accordingly as n is prime or composite.
8
1, 2, 4, 3, 6, 5, 8, 7, 9, 11, 10, 13, 12, 15, 17, 19, 14, 21, 16, 23, 25, 27, 18, 29, 31, 33, 35, 37, 20, 39, 22, 41, 43, 45, 47, 49, 24, 51, 53, 55, 26, 57, 28, 59, 61, 63, 30, 65, 67, 69, 71, 73, 32, 75, 77, 79, 81, 83, 34, 85, 36, 87, 89, 91, 93, 95, 38, 97, 99, 101, 40, 103
OFFSET
1,2
COMMENTS
Inverse of A073846. - Chayim Lowen, Oct 28 2015
FORMULA
a(n) = (4*pi(n)-2*n-1)*(pi(n)-pi(n-1)) + 2*(n - pi(n-1)) - 1, where pi = A000720. - Robert Israel, Oct 28 2015
MAPLE
A073898 :=proc(nmax) local a, n, k; a := [1] ; while nops(a) < nmax do n := nops(a)+1 ; if isprime(n) then k :=2; else k :=1; fi ; while k in a do k := k+2 ; od ; a := [op(a), k] ; od ; RETURN(a) ; end: op(A073898(80)) ; # R. J. Mathar, Jun 27 2007
MATHEMATICA
Table[(4 PrimePi[n] - 2 n - 1)*(PrimePi[n] - PrimePi[n - 1]) + 2 (n - PrimePi[n - 1]) - 1, {n, 72}] (* Michael De Vlieger, Nov 11 2015 *)
PROG
(PARI) vector(100, n, (4*primepi(n)-2*n-1)*(primepi(n)-primepi(n-1))+2*(n-primepi(n-1))-1) \\ Altug Alkan, Oct 29 2015
CROSSREFS
Cf. A073846.
Sequence in context: A135761 A086305 A328047 * A067747 A073846 A110458
KEYWORD
easy,nonn
AUTHOR
Amarnath Murthy, Aug 18 2002
EXTENSIONS
Corrected and extended by R. J. Mathar, Jun 27 2007
STATUS
approved