login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
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.
This sequence exists for at least 800*10^6 terms (see A133242, A133243, A232992). - David Applegate, Nov 01 2007, Nov 15 2007
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
Entries A224221, A224222 are similar sequences which terminate after 20 or so steps, while A224223 and A224229 are similar sequences whose status is also unknown. - N. J. A. Sloane, Apr 05 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
Robert Israel and Reinhard Zumkeller, Table of n, a(n) for n = 0..100000 initial 1000 terms from Robert Israel
David Applegate, C++ Program [For output see A133242, A133243, A232992]
N. J. A. Sloane, Eight Hateful Sequences, a short paper for the 8th Gathering for Gardner, May 2008.
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]
-- Reinhard Zumkeller, Jun 04 2012
(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
For records see A133244, A133245.
Cf. A162846 (where prime(n) occurs).
Sequence in context: A233041 A049567 A293048 * A134207 A133244 A077040
KEYWORD
nonn,nice,look
AUTHOR
Leroy Quet, Oct 14 2007
EXTENSIONS
More terms from Robert Israel, Oct 14 2007
STATUS
approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 24 09:42 EDT 2024. Contains 371935 sequences. (Running on oeis4.)