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.
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
Offset: 0
Examples
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.
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]
- T. D. Noe, Graph of initial terms (out to 10^6)
- N. J. A. Sloane, Eight Hateful Sequences, a short paper for the 8th Gathering for Gardner, May 2008.
- Rémy Sigrist, Colored scatterplot of the sequence (where the color is a function of the parity of n)
- Rémy Sigrist, Colored scatterplot of the sequence (where the color is a function of floor(a(n)/n))
- Rémy Sigrist, Colored scatterplot of the sequence (where the color is a function of floor(2*a(n)/n))
- Rémy Sigrist, Colored scatterplot of the sequence (where the color is a function of Sum_{k=1..n} ((-1)^k * (a(k-1)+a(k))/k))
Crossrefs
Programs
-
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
-
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 *)
-
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
Extensions
More terms from Robert Israel, Oct 14 2007
Comments