|
|
A134204
|
|
a(0)=2; for n > 0, a(n) = smallest prime not occurring earlier in the sequence such that a(n-1) + a(n) is a multiple of n. If no such prime exists, the sequence terminates.
|
|
17
|
|
|
2, 3, 5, 7, 13, 17, 19, 23, 41, 31, 29, 37, 11, 67, 59, 61, 83, 53, 73, 79, 101, 109, 89, 233, 103, 47, 239, 139, 113, 293, 97, 151, 137, 127, 43, 167, 157, 509, 251, 373, 107, 467, 163, 181, 347, 193, 313, 439, 281, 307, 443, 271, 197, 227, 367, 733, 331, 353, 401, 71, 229
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
0,1
|
|
COMMENTS
|
Is this sequence infinite and, if so, is it a permutation of the primes?
This sequence is infinite if and only if a(n-1) never divides n for any n.
The plot of primes less than 10^6 shows an interesting crosshatch pattern. Why? [T. D. Noe, Jul 12 2009] See also the graph of A133244. - N. J. A. Sloane, Apr 06 2013
Empirically, the direction of hatchings is related to the parity of n, and each hatch corresponds to terms with the same value of Sum_{k=1..n} ((-1)^k * (a(k-1)+a(k))/k) (see colorized scatterplots in Links section). - Rémy Sigrist, Nov 07 2017
|
|
LINKS
|
|
|
EXAMPLE
|
The primes that don't occur among terms a(0) through a(6) form the sequence 11,23,29,31,... Of these, 23 is the smallest that when added to a(6)=19 gets a multiple of 7 -- 19+23 = 42 = 6*7. (19+11 = 30, which is not a multiple of 7.) So a(7) = 23.
|
|
MATHEMATICA
|
aa = {a[0]=2, a[1]=3}; a[n_] := a[n] = (an = First[ Complement[ Prime[ Range[1 + PrimePi[ Max[aa]]]], aa]]; While[ Not[ FreeQ[aa, an] && Divisible[ a[n-1] + an, n]], an = NextPrime[an]]; AppendTo[aa, an]; an); Table[a[n], {n, 0, 60}] (* Jean-François Alcover, Oct 17 2012 *)
T. D. Noe, Apr 05 2013, provided the following information about how his plot (see link) was obtained: I computed 500000 points and then plotted up to y = 10^6. Here's the Mma code (which takes a while to run):
t = {2}; Do[k = Ceiling[t[[-1]]/n];
While[p = k*n - t[[-1]]; ! PrimeQ[p] || MemberQ[t, p], k++];
If[2 p < n, Print[{n, p, N[n/p]}]];
AppendTo[t, p], {n, 500000}]
ListPlot[t, PlotRange -> {1, 1000000}, Frame -> True,
PlotStyle -> {PointSize[0.005]}, ImageSize -> 500,
PlotLabel -> "\nA134204(n)\n", GridLines -> Automatic]
With[{nn = 10^3}, Fold[Append[#1, SelectFirst[Prime@ Range[2, Ceiling@ Log2[nn] nn], Function[p, And[FreeQ[#1, p], Divisible[Last@ #1 + p, #2]]]]] &, {2}, Range@ nn]] (* Michael De Vlieger, Oct 16 2017 *)
|
|
PROG
|
(Haskell)
import Data.List (delete)
a134204 n = a134204_list !! n
a134204_list = 2 : f 1 2 (tail a000040_list) where
f x q ps = p' : f (x + 1) p' (delete p' ps) where
p' = head [p | p <- ps, mod (p + q) x == 0]
(PARI) A134204(n, show_all=1, a=2, used=[])={for(n=1, n, show_all & print1(a", "); used=setunion(used, Set(a)); forstep(p=(-a)%n, 9e19, n, isprime(p)||next; setsearch(used, p)&next; a=p; break)); a} \\ M. F. Hasler, Mar 01 2013
|
|
CROSSREFS
|
Cf. A134205, A134206, A134207, A133242, A133243, A131261, A224221, A224222, A224223, A224229, A232992.
Cf. A162846 (where prime(n) occurs).
|
|
KEYWORD
|
|
|
AUTHOR
|
|
|
EXTENSIONS
|
|
|
STATUS
|
approved
|
|
|
|