## Trending News

# hard math problem?

The answer is not 20241.

How many positive integers less than one million has a digit sum of 20, and does not contain any two-digit substring whose digit sum is 7? For example, 123563 is one of those numbers while 435 and 123455 are not.

### 3 Answers

- atsuoLv 61 month ago
You said "The answer is not 20241" , so what is your answer ?

I found that the answer was 20241 as the other answerers said .

If the numbers "07ABCD" , "007ABC" , "0007AB" and "00007A" are

rejected then 19908 becomes the answer . Is your answer 19908 ?

But they are not numbers with 6 digits so they may be counted .

For example , "007553" is "7553" so it must be counted .

- Login to reply the answers

- Jeff AaronLv 71 month ago
I wrote a PERL script to list all the possible integers matching your criteria.

There are 20241 of them.

Source(s): for $n (1..999999) { $sum = 0; for $i (1..length($n)) {$sum += substr($n,$i-1,1);} if ($sum eq 20) { $ok = 1; for $i (1..length($n)-1) {if (substr($n,$i-1,1)+substr($n,$i,1) eq 7) {$ok = 0;}} if ($ok eq 1) { print "$n\n"; ++$count; }}} print $count;- Login to reply the answers

- PuzzlingLv 71 month ago
Two people gave you that answer and I concur with their approach. I would like to see your working to explain why you think the answer is NOT 20241.

Here's some pseudo code that will do the job:

count = 0

For i = 1 to 999999

{

- if DigSum(i) = 20

- {

--- if i contains '07', '16', '25', '34', '43', '52', '61' or '70' then break

--- count = count + 1

. }

}

print count

- Login to reply the answers