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

 Different Sums (Posted on 2004-07-22)
There are 40 ways to make sums of three distinct positive integers total 25. (1+2+22 is such a sum, but 1+12+12 and 1+2+3+19 are not.)

How many different ways can three distinct positive integers sum to 1000?

 See The Solution Submitted by Brian Smith Rating: 3.2500 (4 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
 re(2): With a little help from awk | Comment 3 of 17 |
(In reply to re: With a little help from awk by Sing4TheDay)

Touché -- but you also have to fix the second for(...), and avoid answers including a 0 ("positive integers")...

```
BEGIN {

total = 0;

for (A=1; A<=1000; A++)

{ for (B=A+1; B<=1000; B++)

{

C = 1000-A-B;

if (C>B) { total++; }

}

}

print total

}

```
The new answer is 82834. If I had run the program for 25, I would have noticed that it didn't produce a 40 as an answer...
 Posted by Federico Kereki on 2004-07-22 10:42:59

 Search: Search body:
Forums (0)