A364054 a(1) = 1; for n > 1, a(n) is the least positive integer not already in the sequence such that a(n) == a(n-1) (mod prime(n-1)).
1, 3, 6, 11, 4, 15, 2, 19, 38, 61, 32, 63, 26, 67, 24, 71, 18, 77, 16, 83, 12, 85, 164, 81, 170, 73, 174, 277, 384, 57, 283, 29, 160, 23, 162, 13, 315, 158, 321, 154, 327, 148, 329, 138, 331, 134, 333, 122, 345, 118, 347, 114, 353, 112, 363, 106, 369, 100, 371, 94, 375, 92, 385
Offset: 1
Examples
For n = 2, prime(2-1) = prime(1) = 2; a(1) = 1, so a(1) mod 2 = 1, so a(2) is the least positive integer == 1 (mod 2) that has not yet appeared; 1 has appeared, so a(2) = 3. For n = 3, prime(3-1) = 3; a(2) mod 3 = 0, so a(3) is the least unused integer == 0 mod 3, which is 6, so a(3) = 6. For n = 4, prime(4-1) = 5; a(3) mod 5 = 1, and 6 has already been used, so a(4) = 11.
Links
- Chai Wah Wu, Table of n, a(n) for n = 1..10000
- N. J. A. Sloane, Sketch showing the main features of the graph
- Michael De Vlieger, Log log scatterplot of a(n), n = 1..2^20.
- Michael De Vlieger, 2048 X 2048 raster showing a(n) , n = 1..4194304 in rows of 2048 terms, left to right, then continued below for 2048 rows total. Color indicates terms as follows: black = empty product {1}, red = prime (A40), gold = composite prime power (A246547), bright green = primorial A2110(k), k > 1, light green = squarefree semiprime (A6881 \ {6}), dark green = squarefree composite (A120944 \ {A2110 U A6881}), blue = numbers neither squarefree nor composite (A126706 \ A286708 = A332785), purple = squareful numbers that are not prime powers (A286708).
- Chai Wah Wu, Graph of first 10^8 terms
Crossrefs
Programs
-
Mathematica
a[1] = 1; a[n_] := a[n] = Module[{p = Prime[n - 1], k = 2, s = Array[a, n - 1]}, While[! FreeQ[s, k] || ! Divisible[k - a[n - 1], p], k++]; k]; Array[a, 100] (* Amiram Eldar, Oct 20 2023 *) nn = 2^20; c[] := False; m[] := 0; a[1] = j = 1; c[0] = c[1] = True; Monitor[Do[p = Prime[n - 1]; r = Mod[j, p]; While[Set[k, p m[p] + r ]; c[k], m[p]++]; Set[{a[n], c[k], j}, {k, True, k}], {n, 2, nn}], n]; Array[a, nn] (* Michael De Vlieger, Oct 26 2023, fast, based on congruence, avoids search *)
-
Python
from itertools import count, islice from sympy import nextprime def A364054_gen(): # generator of terms a, aset, p = 1, {0,1}, 2 while True: yield a for b in count(a%p,p): if b not in aset: aset.add(b) a, p = b, nextprime(p) break A364054_list = list(islice(A364054_gen(),30)) # Chai Wah Wu, Oct 22 2023
Comments