Question of the test of the Brazilian naval college

58 Views Asked by At

Determine the number of digits required for the even numbers from 6 to 281 inclusive a) 356 b)830 c)546 d)637 e)365

I'm improving my English yet ...

2

There are 2 best solutions below

2
On BEST ANSWER

Good luck on your Naval Academy Exams!

So verbal language might be less effective in helping you visualize the problem. I will try to convey this with a little bit of python. If of course my assumptions about the problem are valid.

numbers = range(6,282)
even_numbers = []
for i in numbers:
    if i%2!=1:
        even_numbers.append(i)

#print(even_numbers)
#print(len(even_numbers))        

single_digits = []
double_digits = []
triple_digits = []

for i in even_numbers:
    if i<10:
        single_digits.append(i)
    if i in range(10,99):
        double_digits.append(i)
    if i in range(99,282):
        triple_digits.append(i)


print(single_digits)
print(double_digits)
print(triple_digits)

print(len(single_digits)+len(double_digits)*2+len(triple_digits)*3)

Outputs to the console:

[6, 8] [10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98] [100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 144, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 166, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 188, 190, 192, 194, 196, 198, 200, 202, 204, 206, 208, 210, 212, 214, 216, 218, 220, 222, 224, 226, 228, 230, 232, 234, 236, 238, 240, 242, 244, 246, 248, 250, 252, 254, 256, 258, 260, 262, 264, 266, 268, 270, 272, 274, 276, 278, 280] 365

365

What I have done is simply make a list of all numbers from 6-281 for you with a little code and have selected the even numbers and put them into lists based on digit value for you to see.

Mark Fischler is absolutely correct and with a bit more sensitivity towards numbers we might have been fast to realize his answer is correct, and all you had to do was divide it by 2 to get the even or odd values.

I am sure that I could be misinterpreting your question as the word "digits" is some what confusing here... I hope this helps.

TL;DR

Fantastic answer Mark Fischler, Follow his words! The correct answer is 365.

1
On

If this is not a trick question, it is easy. There are $4$ single digit numbers $(6,7,8,9)$. There are $90$ two-digit numbers $(10, 11, \ldots , 99)$. There are $182$ three-digit numbers. Note that the easy way to count is to consider "half-open" ranges of the form "at least $a$ but smaller than $b$." Thus $282 - 100 = 182$. And $10 - 6 = 4$.

The answer is $$1\cdot 4 + 90 \cdot 2 + 182 \cdot 3$$