login
A073846
a(1) = 1; thereafter, every even-indexed term is prime and every odd-indexed term is composite.
19
1, 2, 4, 3, 6, 5, 8, 7, 9, 11, 10, 13, 12, 17, 14, 19, 15, 23, 16, 29, 18, 31, 20, 37, 21, 41, 22, 43, 24, 47, 25, 53, 26, 59, 27, 61, 28, 67, 30, 71, 32, 73, 33, 79, 34, 83, 35, 89, 36, 97, 38, 101, 39, 103, 40, 107, 42, 109, 44, 113, 45, 127, 46, 131, 48, 137, 49, 139, 50
OFFSET
1,2
COMMENTS
Equals A067747 shifted by one position. a(n) = A067747(n-1) [for n>1]. - R. J. Mathar, Apr 01 2007
From Chayim Lowen, Aug 12 2015: (Start)
Consider f(n,k) = a(f(n,k-1)) with f(n,0) = n. Let us also define f(n,k) for negative values of k as well using: f(n,k-1) = A073898(f(n,k)) where A073898(a(n)) = a(A073898(n)) = n. Let us denote the sequence {f(n,i)} for integers i by R#(n). It is clear that if a is a value in R#(b), R#(a) is just R#(b) with a different offset. Therefore, unless there is a need to do otherwise, let us denote each sequence by its lowest value. These sequences can only behave in one of two ways. They can either be periodic with f(n,m) = f(n,0) for some m, or they can include infinitely many distinct values. Here is the behavior of R#(n) for n<=100:
* R#(1), R#(2) and R#(9) are 1-cycles.
* R#(3), R#(5), R#(7), R#(10) and R#(12) are 2-cycles.
* R#(14), R#(62) and R#(84) are 3-cycles.
* R#(92) is a 6-cycle.
* R#(18) is a 22-cycle.
* R#(34) (A261314) has been checked up to f(34,86) = 1091595086717, R#(42) up to f(42,108) = 106838266736, R#(50) up to f(50,98) = 1078406742163, R#(60) up to f(60,80) = 765456394363, R#(74) up to f(74,78) = 687059343029, R#(82) up to f(82,75) = 682580868743 R#(86) up to f(86,74) = 182831963148, R#(88) up to f(88,66) = 719074799059, and R#(98) up to f(98,88) = 641383978721 without repeated values. Hence, their periods are either extremely large or nonexistent (infinite). I conjecture that the latter is the case. Note that these sequences are not necessarily all distinct as any two may simply be the same sequence with a large offset.
For all other n<=100, a(n) is included in one of the above sequences. (End)
Conjecturally, the integers that belong to one of these cycles are: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 35, 37, 39, 41, 43, 47, 53, 62, 84, 87, 92, 121, 127, 132, 135, 181, 199, 205, 317. - Michel Marcus, Mar 07 2021
FORMULA
a(2*n-1) = A018252(n); a(2*n) = A000040(n). - Reinhard Zumkeller, Jan 29 2014
a(n) = A018252(ceiling(n/2))*A000035(n) + A000040(ceiling(n/2))*A059841(n), equivalent to Reinhard Zumkeller's formula. - Chayim Lowen, Jul 29 2015
a(2n)/a(2n-1) ~ log(n). - Thomas Ordowski, Sep 10 2015
MAPLE
N:= 100: # to get a(1) to a(2*N).
p:= ithprime(N):
P, NP:= selectremove(isprime, [$1..p]):
seq(op([NP[i], P[i]]), i=1..N); # Robert Israel, Dec 22 2014
MATHEMATICA
Composite[n_Integer] := FixedPoint[n + PrimePi[ # ] + 1 &, n]; Join[{1}, Flatten[ Transpose[{Table[Prime[n], {n, 1, 35}], Table[Composite[n], {n, 1, 35}]}]]]
f[upto_]:=Module[{prs=Prime[Range[PrimePi[upto]]], comps}, comps= Complement[ Range[upto], prs]; Riffle[Take[comps, Length[prs]], prs]]; f[150] (* Harvey P. Dale, Dec 03 2011 *)
PROG
(Haskell)
import Data.List (transpose)
a073846 n = a073846_list !! (n-1)
a073846_list = concat $ transpose [a018252_list, a000040_list]
-- Reinhard Zumkeller, Jan 29 2014
(PARI) c(n) = for(k=0, primepi(n), isprime(n++)&&k--); n; \\ A002808
a(n) = if (n==1, 1, if (n%2, c(n\2), prime(n/2))); \\ Michel Marcus, Mar 06 2021
(Python)
from sympy import prime, composite
def A073846(n): return 1 if n == 1 else (composite(n//2) if n % 2 else prime(n//2)) # Chai Wah Wu, Mar 09 2021
CROSSREFS
KEYWORD
easy,nonn
AUTHOR
Amarnath Murthy, Aug 14 2002
EXTENSIONS
Edited by Robert G. Wilson v and Benoit Cloitre, Aug 16 2002
STATUS
approved