login
A378500
a(1) = 2, then a(n) = a(n-1) - 2 for n even, a(n) = a(n-1) + 3 for n an odd prime or odd prime power, and a(n) = a(n-1) + 2 otherwise.
1
2, 0, 3, 1, 4, 2, 5, 3, 6, 4, 7, 5, 8, 6, 8, 6, 9, 7, 10, 8, 10, 8, 11, 9, 12, 10, 13, 11, 14, 12, 15, 13, 15, 13, 15, 13, 16, 14, 16, 14, 17, 15, 18, 16, 18, 16, 19, 17, 20, 18, 20, 18, 21, 19, 21, 19, 21, 19, 22, 20, 23, 21, 23, 21, 23, 21, 24, 22, 24, 22, 25
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
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
Sequence in context: A025637 A195826 A331478 * A097065 A084964 A267182
KEYWORD
nonn
AUTHOR
Bill McEachen, Nov 30 2024
EXTENSIONS
Corrected by Charles R Greathouse IV, Dec 01 2024
STATUS
approved