********************** Theorem: a(n)=a(n-1)+1+Sum_{k=1..n-1} d(k) proof (by induction): (Base: a(1) = 1 trivially.) suppose we know a(n-1). we add a new term n to our set {1..n-1}. a(n) = all (arith.) sequences without new term + sequences with new term = a(n-1) + (single seq. consisting of just the new term) + (sequences of len > 1 which end with the new term) = a(n-1)+ 1 + (len > 1,terms ending with new term) To get the last term, loop over difference between max and min element of the subsets of {1...n}. Every divisor of a given difference i (from 1 to n-1 inclusive) gives us an arith. seq. Thus, the last term is the sum over i of d(i) => Sum_{i=1..n-1} d(k) - Daniel Hoying, May 19, 2020 **********************