A337490 a(0)=1; for n > 0, a(n) = the greatest common divisor (GCD) of n and the sum of all previous terms if the GCD is not already in the sequence; otherwise a(n) = a(n-1) + n.
1, 2, 4, 7, 11, 5, 6, 13, 21, 30, 10, 21, 33, 46, 14, 29, 45, 62, 18, 37, 57, 78, 22, 45, 69, 94, 26, 53, 81, 110, 140, 171, 203, 236, 270, 305, 341, 378, 416, 39, 79, 120, 162, 205, 249, 294, 340, 387, 3, 52, 102, 17, 69, 122, 176, 231, 287, 344, 402, 461, 521, 582, 644, 707, 771, 836, 902, 969
Offset: 0
Keywords
Examples
a(2) = 4 as the sum of all previous terms is a(0)+a(1) = 3, and the GCD of 3 and 2 is 1, which has already appeared in the sequence. Therefore a(2) = a(1) + n = 2 + 2 = 4. a(4) = 11 as the sum of all previous terms is a(0)+...+a(3) = 14, and the GCD of 14 and 4 is 2. However 2 has already appeared so a(4) = a(3) + n = 7 + 4 = 11. a(5) = 5 as the sum of all previous terms is a(0)+...+a(4) = 25, and the GCD of 25 and 5 is 5, and as 5 has not previous appeared a(5) = 5.
Links
- Scott R. Shannon, Table of n, a(n) for n = 0..10000
- Scott R. Shannon, Graph of the terms for n=0..2500. This includes the last known decrease in the sequence, n(1974) = 42.
- Scott R. Shannon, Graph of the terms for n=0..10000000.
Crossrefs
Programs
-
PARI
lista(nn) = {my(va = vector(nn), s=0); va[1] = 1; s += va[1]; for (n=2, nn, my(g = gcd(n-1, s)); if (#select(x->(x==g), va), va[n] = va[n-1]+n-1, va[n] = g); s += va[n];); va;} \\ Michel Marcus, Sep 05 2020
Comments