A264100 Sum of the lengths of the arithmetic progressions in {1,2,3,...,n}, including trivial arithmetic progressions of lengths 1 and 2.
0, 1, 4, 12, 26, 50, 82, 130, 188, 265, 358, 473, 602, 765, 944, 1151, 1386, 1657, 1948, 2284, 2642, 3048, 3490, 3972, 4480, 5056, 5666, 6322, 7022, 7784, 8578, 9452, 10360, 11337, 12366, 13453, 14592, 15831, 17110, 18453, 19856, 21357, 22902, 24551
Offset: 0
Keywords
Examples
For n = 3 the arithmetic progressions are (1), (2), (3), (1, 2), (1, 3), (2, 3), (1, 2, 3) and the respective lengths are (1), (1), (1), (2), (2), (2), (3), so a(3) = 1 + 1 + 1 + 2 + 2 + 2 + 3 = 12. The first difference at 2, sequences ending with 3, are (3), (1, 3), (2, 3), and (1, 2, 3), total length 8 = 12-4. The second difference at 2, sequences starting with 1 and ending with 4 are (1, 4) and (1, 2, 3, 4), total length 6 = 26 - 2*12 +4.
Programs
-
PARI
vector(50, n, n--; n + sum(k=2, n, k*floor((n-1)/(k-1))*(2*n-(k-1)*floor((n+k-2)/(k-1)))/2)) \\ Altug Alkan, Nov 04 2015
Formula
a(n) = n + Sum_{k=2..n} k*floor((n-1)/(k-1))*(2*n-(k-1)*floor((n+k-2)/(k-1)))/2.
Comments