A307213 Divide the natural numbers into sets of successive sizes 3,4,5,6,7,...,, starting with {1,2,3}. Cycle through each set until you reach a prime; if the prime was the n-th element in its set, jump to the n-th element of the next set.
1, 2, 5, 9, 10, 11, 16, 17, 23, 30, 31, 39, 40, 41, 50, 51, 52, 43, 53, 64, 65, 66, 67, 79, 92, 93, 94, 95, 96, 97, 111, 112, 113, 128, 129, 130, 131, 147, 148, 149, 166, 167, 185, 186, 187, 169, 170, 171, 172, 173, 192, 193, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 244, 245, 246, 247, 248, 249, 250, 229
Offset: 1
Keywords
Examples
The first set is {1,2,3}. We look at 1 then 2. 2 is prime, and it is the second number in the set. The next set is {4,5,6,7}. So we jump to the second element, 5. 5 is also prime, so we jump to the second element of the next set, {8,9,10,11,12}, which is 9, etc. If we reach the end of a set without reaching a prime, we loop back to the first element, which is the only way for a(n) < a(n-1) to happen.
Links
- Rémy Sigrist, Table of n, a(n) for n = 1..10000
- Rémy Sigrist, PARI program for A307213
Programs
-
Mathematica
Nest[Append[#1, {If[#3 <= Length@ #4, #3, #3 - Length@ #4], If[#2 == #3, {#4[[#3]]}, Join[#4, #4][[#2 ;; #3]]], #4}] & @@ {#1, #2, If[PrimeQ[#3[[#2]] ], #2, #2 + FirstPosition[RotateLeft[#3, #2], ?PrimeQ][[1]] ], #3} & @@ {#1, #2, Range[#3, #3 + #4]} & @@ {#, #[[-1, 1]], 1 + Max@ #[[-1, -1]], Length@ # + 2} &, {{#1, #2[[1 ;; #1]], #2} & @@ {FirstPosition[#, ?PrimeQ][[1]], #}} &@ Range@ 3, 19][[All, 2]] // Flatten (* Michael De Vlieger, Mar 31 2019 *)
-
PARI
See Links section.
Extensions
Edited by N. J. A. Sloane, Jul 13 2019
Comments