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?
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?
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