login
Start with a(1) = 1, a(2) = 2. Thereafter, if a(n) is prime, a(n+1) = a(n) + 1. If a(n) is composite, look for its greatest factor other than itself (k, say) earlier in the sequence. If k is found, a(n+1) = a(n) + the number of steps back to the most recent appearance of k. If k is not found, a(n+1) = a(n) - k.
2

%I #43 Sep 13 2019 22:47:55

%S 1,2,3,4,6,8,10,5,6,12,13,14,7,8,18,9,22,11,12,22,24,26,37,38,19,20,

%T 39,55,65,83,84,42,21,41,42,44,60,30,15,46,23,24,47,48,50,25,63,77,

%U 107,108,54,27,63,83,84,104,52,87,58,29,30,52,92,115,138,69,94,118,59

%N Start with a(1) = 1, a(2) = 2. Thereafter, if a(n) is prime, a(n+1) = a(n) + 1. If a(n) is composite, look for its greatest factor other than itself (k, say) earlier in the sequence. If k is found, a(n+1) = a(n) + the number of steps back to the most recent appearance of k. If k is not found, a(n+1) = a(n) - k.

%C It is unknown whether every natural number eventually appears in the sequence, but some have notably late entry points. For instance, a(n) = 28 for the first time (possibly only time) at n = 582. 280 first appears at n = 16175. 508 and 624 are the only values less than 1000 that do not appear in the first 50000 terms. After n = 4, the first time a(n) = n is at term 766. Thereafter, a(n) = n at 1952, 4682, 6367, 6368, and not again within the first 50000 terms.

%H Max Tohline, <a href="/A322572/b322572.txt">Table of n, a(n) for n = 1..20000</a>

%t gf[n_] := n/FactorInteger[n][[1, 1]]; s = {1, 2}; Do[a = s[[-1]] + If[PrimeQ[s[[-1]]], 1, m = If[(p = Position[s, _?(# == (k = gf[s[[-1]]]) &)]) == {}, -k, Length[s] - p[[-1, 1]]]]; AppendTo[s, a], {100}]; s (* _Amiram Eldar_, Sep 06 2019 *)

%o (PARI) { a = vector(69); for (n=1, #a, if (n==1, a[n] = 1, n==2, a[n] = 2, isprime(a[n-1]), a[n] = a[n-1]+1, d = divisors(a[n-1]); k = d[#d-1]; a[n] = a[n-1]-k; forstep (m=n-2, 1, -1, if (a[m]==k, a[n] = a[n-1] + n-1 - m; break))); print1 (a[n] ", ")) } \\ _Rémy Sigrist_, Sep 06 2019

%Y Cf. A032742, A326487.

%Y Similar to the Van Eck sequence, A181391. See also A309035.

%K nonn

%O 1,2

%A _Max Tohline_, Aug 29 2019