OFFSET
1,1
COMMENTS
Asymptotically the sequence should reach long periods of stasis, with rare increases with each new prime so as to yield a strict permutation of the positive integers if duplicates are removed.
LINKS
Bill McEachen, Table of n, a(n) for n = 1..10000
FORMULA
a(n) = a(n-1) - 2 for n even.
a(n) = a(n-1) + 3 for n an odd prime or odd prime power.
a(n) = a(n-1) + 2 for n an odd composite not a prime power.
a(n) ~ n/log n. - Charles R Greathouse IV, Dec 01 2024
EXAMPLE
3 is prime so a(3) = a(2) + 3 = 0 + 3 = 3. 4 is even so a(4) = a(3) - 2 = 3 - 2 = 1.
MATHEMATICA
Module[{n = 1}, NestList[# + Which[EvenQ[++n], -2, PrimePowerQ[n], 3, True, 2] &, 2, 100]] (* Paolo Xausa, Dec 06 2024 *)
PROG
(PARI) first(n)=my(v=vector(n)); v[1]=2; for(k=2, n, v[k]=v[k-1]+if(k%2==0, -2, isprimepower(k), 3, 2)); v \\ Charles R Greathouse IV, Dec 01 2024
CROSSREFS
KEYWORD
nonn
AUTHOR
Bill McEachen, Nov 30 2024
EXTENSIONS
Corrected by Charles R Greathouse IV, Dec 01 2024
STATUS
approved