a(n) = { my(oz = 0, nz = 3); while(nz <= n, oz = nz; nz = nextzero(nz); ); binomial(n+1, 2) - binomial(oz + 1, 2) } nextzero(n) = { if(n == 0, return(3)); my(c = binomial(n+1, 2), d = divisors(2*c)); for(i = 2, #d, if(d[i] > n && if(binomial((d[i]), 2) - c > 0 && (binomial((d[i]), 2) - c)%(d[i]) == 0, return(d[i]); ); ); ); } first(n) = { n--; my(res = [1..n]); res[1] = 1; for(i = 2, n, if(res[i-1] > 0, if(res[i-1]%i == 0, res[i] = 0 , res[i] = res[i-1] + i; ); , res[i] = res[i-1] + i ); ); concat(0, res) } firstzeros(n) = { my(res = vector(n)); for(i = 2, n, res[i] = nextzero(res[i-1]); ); res }