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.
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
Keywords
Examples
3 is prime so a(3) = a(2) + 3 = 0 + 3 = 3. 4 is even so a(4) = a(3) - 2 = 3 - 2 = 1.
Links
- Bill McEachen, Table of n, a(n) for n = 1..10000
Programs
-
Mathematica
Module[{n = 1}, NestList[# + Which[EvenQ[++n], -2, PrimePowerQ[n], 3, True, 2] &, 2, 100]] (* Paolo Xausa, Dec 06 2024 *)
-
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
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
Extensions
Corrected by Charles R Greathouse IV, Dec 01 2024
Comments