Sherlock number is a number in which the sum of its digits is an even number. You are given an integer input N. Your task is to return the count of all the Sherlock numbers between 0 to N (O
Answers
Answered by
0
Answer:
2,4,6,8,10,12,14,16,18,19
Answered by
0
Answer: The count of all the Sherlock numbers between 0 to N = 9 + 2N
Step-by-step explanation:
To obtain an even number, we need, sum of 2 odd numbers or sum of 2 even numbers. (sum of an odd and an even number cannot be even)
Eg. 11,13,15,17,19,20,22,24,26,28
So, we find that from every 10 numbers,after 10, 5 numbers will be Sherlock number.
If N= 20, Sherlock numbers = 5
If N= 30, Sherlock numbers = 10
If N= 40, Sherlock numbers = 15 ....and so on.
Similar questions