My attempt at a proper formula, although I know it's not quite right:
given k, let m = [p(k)^2 - p(k)]/6, where p(k) = the kth prime number, then:
f(k) = m + sum [ from i = 1 to k, sum ( from j = 3 to k, (-1)^i * 2^i *floor[m/ product ( from L = j to k, p(L) )] +n(i,j) ) ]
where n(i,j) is an...