How many positive even integers up to 1000 (inclusive) have an even digit sum?
Details and assumptions
The digit sum of a number is the sum of all its digits. For example the digit sum of 1123 is 1 + 1 + 2 + 3 = 7 .
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
Nice solution! :)
what about 100, 300, 500, 700, 900
Log in to reply
They all have odd digit sum! Say 1 0 0 , digit sum is 1 + 0 + 0 = 1 and 1 is odd, hence NOT satisfying the question
I considered 0 first...then i subtracted 1 from 250...249....good q...
What about 1000, the question they asked 1000 inclusive.? So,answer will be 250...?
Log in to reply
Notice that the digit sum of 1 0 0 0 is 1 + 0 + 0 + 0 = 1 , but 1 is odd. So, it is rejected.
Sorry forgot to mention that 1000 is rejected anyway.
This problem can be broken down into three portions:
1 : The integer has 1 digit.
2 : The integer has 2 digits.
3 : The integer has 3 digits.
We can disregard the case of 4 digits, since 1000 does not have an even digit sum.
We first note that in order for an integer to be even, it needs to have an even ones' digit. We can now tackle each case separately. In the explanations, let it be noted that E means even and O means odd.
1 digit:
This set contains only 4 integers of the form E which satisfy the given conditions, namely: ( 2 , 4 , 6 , 8 ) .
2 digits:
In order for a 2 digit even integer to have an even digit sum, it must have the form E , E . This yields a total of ( 4 ∗ 5 ) or 20 possible integers.
3 digits:
In order for a 3 digit even integer to have an even digit sum, it must have the form E , E , E or O , O , E . For the first sub-case, there are a total of ( 4 ∗ 5 ∗ 5 ) or 100 possible integers. For the second sub-case, there are a total of ( 5 ∗ 5 ∗ 5 ) or 125 possible integers.
Combining all of these cases together, we yield that there are a total of ( 4 + 2 0 + 1 0 0 + 1 2 5 ) or 2 4 9 integers.
Xctly how I did it too :) ... (Y)
Nice Soln :)
How about O , O in two digits?
Log in to reply
Yes it has an even digit sum but it is not an even integer.
O,O may have an even digit sum but it is an odd number. Hence it contradicts the given criteria.
For an even number to have an even digit sum, the digits must be either odd-odd-even or even-even-even. This is because there must be an even number of digits that are odd. There are 5 even digits: 0 , 2 , 4 , 6 and 8 . Therefore, there are 5 × 5 × 5 = 1 2 5 possibilities for a number that has all even digits. There are also 5 odd digits: 1 , 3 , 5 , 7 and 9 . So there are, again, 5 × 5 × 5 = 1 2 5 numbers that have odd-odd-even as their digits. Therefore, the answer would be 2 5 0 . However, this would include 0 0 0 , which is not positive. Therefore, the answer is 2 5 0 − 1 = 2 4 9 .
Nice....The allowance of leading zeroes facilitates easier calculations...I calculated it separately
My Python one-liner:
len(filter(lambda x: x%2==0 , map(lambda x: sum(map(int,str(x))) ,filter(lambda z: z%2==0 ,[x for x in range(1,1001)]))))
Let us divide in 3 cases according to the digits:
Therefore the total is 4 + 2 0 + 2 2 5 = 2 4 9 .
To simplify the solution, consider all three digit numbers as we exclude 1000 in the count because the digit sum is odd (1).
X X X
each digit X can be even or odd. We are to consider only the even numbers so the last digit should be even
X X E
For a sum to be even we should have an even number of odd digits regardless of the number of even digits. In this case, we should have either all even or 1 even and 2 odd digits.
Our possible combinations would then be the following: E E E, O O E
The number of even and odd digits we could use is 5 each (0 is applicable as leading 0 digits will still result to a positive integer less than 1000)
O O E = 5 x 5 x 5 = 125 E E E = 5 x 5 x 5 = 125
But we are only to consider positive integers, which means we should exclude the possibility of 0 0 0.
O O E = 125, E E E = 125 - 1 = 124
O O E + E E E = 125 + 124 = 249
Final Answer: 249
Assume that a number less than 1000 has the form "XXX" where X is a placeholder for a digit. An even number will have the form "XXE" where E is a placeholder for an even digit. Additionally, Even + Even = Even and Odd + Odd = Even. This means there are two forms of even numbers less than 1000 whose digits sum to an even number (E = even digit, O = odd digit):
In the first case, EEE, all three digits are even, so the sum will be even. Since there are five even digits (0, 2, 4, 6, 8), we have 5 × 5 × 5 = 1 2 5 . However this allows for the case "000" which is not a number. Hence we must subtract 1, which gives us 124 valid numbers for the case EEE. Note that this accounts not only for 3 digit numbers but also for 2 digit and 1 digit numbers when the first two digits are 0 (example: 004 = 4, 028 = 22)
In the second case, OOE, the first two odd digits sum to an even number, and when added to the last digit, will result in an even digit sum. Since there are 5 odd digits (1, 3, 5, 7, 9) and 5 even digits, we have 5 × 5 × 5 = 1 2 5 . We do not have any cases that would not be valid positive integers. so we have the full 125 numbers for the case OOE.
If we add our totals, 1 2 4 + 1 2 5 = 2 4 9
I forgot one thing - The problem states up to 1000 (inclusive). However since 1 + 0 + 0 + 0 is odd, we can discard 1000 as a possible solution.
First you notice that for the sum of the digits of an even number to be also even you need to have this : if it is a number with 2 digits the 2 digits need to be even numbers, and if it is a 3 digit number you need to have or a odd,odd,even number (for example 334), or a even.even,even number (for example 464) (remember that the last digit is always even). So you have: 0,2,4,6,8 of one digit. then you have the two digit numbers 20,22,24,26,28 and the same with 40... 60.. 80.. Finally with 3 digits you have 110,112,114,116,118, 130. 132... 150.. 170...190... that's 25 numbers. Then you multiply this by 9 (because you do the same with 200,300...900). So in the end you have: 4 + 5x4 + 9x25 = 249
In order for the digit sum to be even, all three digits must be even, or the first two must be odd and the third digit even. If EEE, then there are 5 x 5 x 5 such numbers. If OOE, then there are 5 x 5 x 5 such numbers. Subtract the case of 000 (the number zero) since the questions refers to positive even integers. Thus the answer is 125 + 125 - 1 = 249.
Problem Loading...
Note Loading...
Set Loading...
Let the number described be of the form a b c . It doesn't matter if a = 0 or if b = 0 when a = 0 because we also need to consider 2 digit and 1 digit numbers.
c can be any one of { 0 , 2 , 4 , 6 , 8 } .
Then be need to consider cases for b :-
Case 1) b is even a is even because a + b + c has to be even. Thus there are 5 values each for a and b This gives total of 5 × 5 × 5 = 1 2 5 numbers of this form
Case 2) b is odd Now a is odd because a + b + c has to be even. Again there are 5 values each for a and b This gives total of 5 × 5 × 5 = 1 2 5 numbers.
We should note that we have also considered 0 in our list. So it is 2 4 9 numbers and not 2 5 0 .