+0

# i've asked this question once already but a guest copied and pasted a wrong answer from an old forum...

0
121
8

How many 10-digit numbers are there, such that the sum of the digits is divisible by 2?

Note that the answer is not 4,500,000,000, it's asking for the SUM of the digits to be divisible by 2, not the number itself.

Aug 25, 2020
edited by uvacowdo  Aug 25, 2020

#1
0

What the SUM of the digits of this number? 1,000,000,001 =2. Is 2 divisible by 2? Next number:1,000,000,003 =4. Is 4 divisible by 2? Next number: 1,000,000,005 =6. Is 6 divisible by 2?....etc.

What are you looking for? Can you give an example, say of a much smaller number, explaining exactly what you want?

Aug 25, 2020
#5
0

oh, i'm sorry.

for example:

sum of digits of 23: 5

sum of digits of 5287: 5+2+8+7 = 22

do you understand or is it unclear? sorry if it was not clear before. uvacowdo  Aug 25, 2020
#2
0

Aug 25, 2020
#3
0

uvacowdo: Is 4,500,000 the right answer?

Guest Aug 25, 2020
#4
0

no... sorry because it is not asking for the number itself to be divisible by two, it is asking for the sum of the digits to be div. by 2...thanks for trying!

uvacowdo  Aug 25, 2020
#6
0

But that is exactly the reason it begins with 1,000,000,001. This number is NOT divisible by 2!!. Only the SUM of its digits, which is; 1 + 1 = 2 is divisible by 2. Do you actually understand the answer that was given to you? Similarly, the last number: 9,999,999,999 is NOT divisible by 2, but the SUM of its digits which equals 90 is divisible by 2.

Do you see it?

Aug 25, 2020
#7
0

OK young person! Here is a computer code that I wrote in Python 3 to count ALL 10-digit numbers whose SUM is divisible by 2!!

%%time
# Efficient Python 3 program to sum up the #
# multiples of digit n in a range of 2 - 10-digit integers #
# E.G. "What is the total  number and sum of all 3-digit integers that are
#  mutiples of 7, or are divisible by 7?". Answer =70,336 #

# find the Sum of having n digit
# and divisible by the number
def totalSumDivisibleByNum(digit, number):

# compute the first and last term
firstnum = pow(10, digit - 1)
lastnum = pow(10, digit)

# first number which is divisible
# by given number
firstnum = (firstnum - firstnum % number)+number

# last number which is divisible
# by given number
lastnum = (lastnum - lastnum % number )

# total divisible number
count =int ((lastnum - firstnum) / number+1  )
print("Total count =", f"{count:,d}")
# return the total sum
return int(((lastnum + firstnum) * count) / 2)

# Driver code
digit =10 ; num = 2

print("Total Sum =", f"{totalSumDivisibleByNum(digit, num):,d}")

Total count = 4,500,000,000
Total Sum = 24,750,000,004,500,000,000

Wall time: 0 ns

Aug 25, 2020
#8
0

Yes, that is correct. Thank you so much!!

(you should create an account so that when you answer questions you can get points) uvacowdo  Aug 25, 2020