Find all series of consecutive positive integers whose sum is exactly 10,000.
__________________________________
What if we don't require the consecutive integers to (all) be positive?
I think it illustrates the argument that some problems are easy to do with a computer yet by doing something worthwhile is bypassed.
//find consecutive integers adding up to 10000
// key observation - cant start before -9999 and cant end after 10000
// or more generally - cant start before 1 - Sum and cant end after Sum
#include <iostream.h>
void prnConsecSumSets(SumToCompute) {
int i, m, sum;
for ( i = 1 - SumToCompute; i <= SumToCompute; i++) {
sum = m = i;
while (sum <= SumToCompute)
if ((sum += (++m)) == SumToCompute)
cout << "{" << i << ", . . . , " << m << "}" << endl;
}