cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

Showing 1-3 of 3 results.

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.

Original entry on oeis.org

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

Views

Author

Leroy Quet, Oct 14 2007

Keywords

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

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.
		

Crossrefs

For records see A133244, A133245.
Cf. A162846 (where prime(n) occurs).

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

A133242 Indices n such that A134204(n) < n.

Original entry on oeis.org

12, 201, 379, 474, 588, 868, 932, 1604, 1942, 2006, 3084, 4800, 7800, 9666, 9700, 10794, 10956, 11074, 11140, 11176, 14112, 16420, 16436, 16499, 17330, 17478, 18475, 20784, 21118, 21410, 22004, 22078, 22510
Offset: 1

Views

Author

Robert Israel, Oct 15 2007

Keywords

Examples

			The first few exceptionally small terms in A134204 that give rise to this sequence and A133243 are b(12) = 11, b(201) = 173, b(379) = 257, b(474) = 263, b(588) = 571, b(868) = 631, b(932) = 887, ..., where b(i) = A134204(i).
		

Extensions

Corrected and extended by David Applegate, Oct 15 2007

A232992 Let b(i) = A134204(i) and c(n) = A133242(n); a(n) is the number of primes p <= c(n) such that p is not in {b(0), b(1), ..., b(c(n)-1)}.

Original entry on oeis.org

1, 1, 2, 1, 1, 2, 2, 3, 2, 1, 2, 3, 6, 7, 6, 7, 7, 7, 6, 5, 7, 12, 11, 10, 10, 9, 10, 12, 11, 12, 11, 10, 9, 9, 8, 8, 8, 9, 8, 8, 8, 7, 10, 16, 16, 16, 19, 18, 17, 16, 15, 15, 16, 16, 17, 16, 15, 16, 16, 19, 19, 20, 20, 19, 18, 17, 16, 17, 20, 19, 20, 19, 18, 18, 19, 23, 24, 23, 25, 24, 25, 27, 26, 27, 27, 26, 25, 25
Offset: 1

Views

Author

N. J. A. Sloane, Dec 13 2013

Keywords

Comments

Computed by David Applegate, Oct 2007.
Arises from studying the question of whether A134204 is an infinite sequence.

Examples

			Terms b(0) through b(12) of A134202 are (ignore the periods, which are just for alignment):
i:... 0, 1, 2, 3,. 4,. 5,. 6,. 7,. 8,. 9, 10, 11, 12
b(i): 2, 3, 5, 7, 13, 17, 19, 23, 41, 31, 29, 37, 11
c(1) = 12 is the first i for which b(i)<i.
Then a(1) is the number of primes p <= 12 that are not in the set {b(0), ..., b(11)} = {2, 3, 5, 7, 13, 17, 19, 23, 41, 31, 29, 37}.
Only p = 11 is missing, so a(1)=1.
		

Crossrefs

Showing 1-3 of 3 results.