OFFSET
1,1
COMMENTS
The corresponding sequence with a(1) = 0 or 1 is a constant sequence. This is also true with a(1) = -1 for a(n+1) = Sum_{i=1..|a(n)|} floor(a(n)/i), but when a(1) = -2 that sequence begins -2, -3, -6, -16, -61, -322, -2227, .... The PARI program below uses the fact mentioned in the example; it calculates the first 15 terms over 16000 times faster than a brute force program simply using s = sum(i = 1, s, s\i). In particular, for any positive integer j, j is a summand exactly floor(a(n)/j) - floor(a(n)/(j+1)) times when calculating a(n+1).
FORMULA
From Anthony Saint-Criq, Feb 09 2022: (Start)
a(n+1) = Sum_{i>=1} floor(a(n)/i).
a(n+1) = A006218(a(n)), since the area covered by overlapping partitions of n yields a partition of another integer.
(End)
EXAMPLE
a(5) = 10 + 5 + 3 + 2 + 2 + 1 + 1 + 1 + 1 + 1 = 27 since a(4) = 10. In general, this preponderance of relatively large numbers of each of the smallest summands simplifies these calculations. (This pattern is somewhat different when the terms are negative.)
PROG
(PARI)
{a(n, s = 2) =
local(j, ss, t);
if(s < 0,
print("This function only accepts nonnegative starting");
print("terms, for which it is (partially) optimized.");
return());
for(k = 1, n, print1(s, ", ");
if(k == n, return(s));
ss = s; j = 1;
while((t = s\j - s\(j+1)) > 1,
ss += t*j;
j++);
s = ss + sum(i = 2, s\j, s\i))}
a(21)
(Python)
from math import isqrt
def A006218(n):
r = isqrt(n)
return 2*sum(n//k for k in range(1, r+1)) - r**2
def afind(an=2):
while True:
print(an:=A006218(an), end=", ")
afind() # Michael S. Branicky, Feb 20 2022
CROSSREFS
KEYWORD
nonn
AUTHOR
Rick L. Shepherd, Jul 19 2013
EXTENSIONS
a(22)-a(23) from Michael S. Branicky, Feb 20 2022
STATUS
approved
