All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > Numbers
10,000 (Posted on 2004-07-21) Difficulty: 3 of 5
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?

See The Solution Submitted by SilverKnight    
Rating: 2.6000 (5 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
a computer program - a lesser solution | Comment 7 of 10 |


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;
}
  Posted by vectorboy on 2004-07-21 23:44:47
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (12)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information