TCS
Company
how many 1s are present between 1 to 1000?
Read Solution (Total 2)
-
- This one takes some thinking...
If we have the numbers written out like this:
000001
000002
000003
...
100000
Let's look at the patterns in each position.
For every 10 sequential numbers we have 1 "1" in the ones place.
For every 100 sequential numbers we have 10 "1"s in the tens place.
For every 1000 sequential numbers we have 100 "1"s in the hundreds place.
Let's look at 1000 sequential numbers.
For every 1000 sequential numbers we have 100 "1"s in the ones place. (100 single digits)
For every 1000 sequential numbers we have 100 "1"s in the tens place. (10 blocks of 10)
For every 1000 sequential numbers we have 100 "1"s in the hundreds place. (1 block of 100)
For every 1000 sequential numbers we have 1 "1" in the thousand's place. (1 single digit)
It looks like for the number of digits n, we have
1 + (n-1)*10^(n-2) ones.
Let's try this out on a small range of numbers so we can see if it is correct. If we look at the range 1-100, I would expect our equation to come out with 10 ones in the one place and 10 ones in the tens place and one one in the hundreds, for a total of 21 ones.
n = 3 digits, so our equation is:
1 + (3-1)*10^(3-2) = 1 + 2*10 = 2
1-1000. Here, I would expect 100 ones in the ones place (each one single), 100 ones in the tens place (ten blocks of ten), 100 ones in the hundreds place (one block of 100) and one one in the thousands. This is 301 ones.
n = 4 digits, so our equation is:
1 + (4-1)*10^(4-2) = 1 + 3*(100) = 301 - 13 years agoHelpfull: Yes(10) No(5)
- It looks like for the number of digits n, we have
1 + (n-1)*10^(n-2) ones.
at the range 1-100, I would expect our equation to come out with 10 ones in the one place and 10 ones in the tens place and one one in the hundreds, for a total of 21 ones.
n = 3 digits, so our equation is:
1 + (3-1)*10^(3-2) = 1 + 2*10 = 21 - 13 years agoHelpfull: Yes(1) No(12)
TCS Other Question