first(n) = customparts(abundantsUpto(n), n) customparts(v, n) = { my(res = vector(n+1)); res[1] = 1; for(i = 1, #v, for(j = v[i]+1, n+1, res[j] += res[j - v[i]] ) ); res } abundantsUpto(n) = {my(res = List()); for(i = 1, n, if(sigma(i) > n<<1, listput(res, i) ) ); res }