One day, when Fred was bored, he listed the integers from 1 to 9001 on the board. Let the digit that he wrote the most be a , and the digit that he wrote the least be b . Find a + b .
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
Can you show that 0 doesn't occur as much as 9? (The main difficulty of the problem)
Log in to reply
What makes it so difficult? 9 appears as a hundreds digit of a three digit number and tens digit of a two digit number 110 times. 0 appears as such none of the time.
Log in to reply
I don't understand why this problem is rated 2057, either.
Log in to reply
@Minimario Minimario – Probably because many users got the wrong answer, I think..
This problem is quite tricky. I suppose many users only count the digits of 1 until 9 excluding the 0 digit (I almost answered TEN!).
Log in to reply
@Ammar Fathin Sabili – yeah that exactly what happened to me
@Ammar Fathin Sabili – Me 'two'! (Plus, the rating for me was 2001)
@Ammar Fathin Sabili – I did the same :D
@Ammar Fathin Sabili – I did answer 10, just because I didn't stop to consider 0.
Why 110 Times?
subscribe to pewdiepie and help youtube.com live
Every other number has a number like 99, 11, 22, 33, but there is no 00. Therefore, there are less 0's than any other digit.
Did n"t seem to be level 5th question.
0 confused as much as 9 .
Same I don't understand why it's rated so high either....the problem is quite trivial imo. took me <10s =.=
Log in to reply
Exactly, the answer was pretty obvious. It isn't simply challenging enough to be a level 5 question.
as 0 after 10 ,20 30 etc it will come 890 times whereas 9 will come 891 times 1 more as in 9001.....
Log in to reply
subscribe to pewdiepie and help youtube.com live and stay alive
fifth level seems some hard
i forget the 0...
I do not understand how people got one as the answer. Can someone please explain this to me?
I used the same technique... It was quite simple 😏
I don’t understand To be honest I just guessed
The real question is who would do that when they are bored.
I forgot the zero.........
First, we notice 1-9 are used the same time N in the sequence 1-9999 and 0 is M as M<N.
We can easily find N which is 4000. For M we have:
So, finally M=2889.
Now we have to remove the digits from the sequence 9002-9999. We have:
Finally, 1 is used 3 7 0 1 times (max value) and 0 is used 2 5 9 4 times (min value) which makes a = 1 and b = 0 so a + b = 1 .
For programmers the following C code directly shows a and b :
#include <cstdlib>
#include <iostream>
using namespace std;
int main()
{
int t[10] = {0};
int i, j;
for(i=1;i<=9001;i++){
j=i;
while(j){
t[j%10]++;
j/=10;
}
}
for(i=0;i<10;i++)
printf("%d=[%d] ", i, t[i]);
printf("\n");
return 0;
}
The output is:
0=[2594] 1=[3701] 2=[3700] 3=[3700] 4=[3700] 5=[3700] 6=[3700] 7=[3700] 8=[3700] 9=[2702]
brilliant approach
Beautiful!
brilliant
brilliant
Brilliant
Corresponding code for beginner java programmers:
public class Digits
{
int d0 = 0; int d1 = 0; int d2 = 0; int d3 = 0; int d4 = 0; int d5 = 0; int d6 = 0; int d7 = 0; int d8 = 0; int d9 = 0;
public void main()
{
for(int i = 1 ; i < 9002 ; i++)
{
dig(i);
}
System.out.println(d0);
System.out.println(d1);
System.out.println(d2);
System.out.println(d3);
System.out.println(d4);
System.out.println(d5);
System.out.println(d6);
System.out.println(d7);
System.out.println(d8);
System.out.println(d9);
}
public void dig(int n)
{
while(n >= 1)
{
int d = n % 10;
n = n / 10;
switch(d)
{
case 0: d0++;
break;
case 1: d1++;
break;
case 2: d2++;
break;
case 3: d3++;
break;
case 4: d4++;
break;
case 5: d5++;
break;
case 6: d6++;
break;
case 7: d7++;
break;
case 8: d8++;
break;
case 9: d9++;
break;
}
}
}
}
We can also look at it from any range of the form 0 to 99999...
and so on...
This issue only occurs for humans because of convention. We do not have bounds or storage capacities. On a computer, a 0 as a 8-bit binary integer is actually stored as 00_000_000.
Can Someone explain to me why N = 4000?
Petro you must have a lot of time on your hand
0 Appears '2350' times and 1 appears '3169' times, remaining are used '3168' times except 9, that is used '2441' times (from 1 to 9001)
Log in to reply
your calculations for how many times digits are used are not correct. This problem should have been, for example find A+B where they represent not the digits used the most and the least but rather the exact values of their usage i.e. 3701 and 2594. This would better test the logic applied for the problem.
Think of a number as this : _ _ _ _ that is, four places to be filled up with digits.
Now certainly, to give each digit its fair share of presence, we should start with 0000 and go up to 9999. Doing so, we would do justice to every digit.
But bored as he was, Fred din't have the energy to enter all those useless zeros as prefixes ( for example, he wrote 24 instead of 0024). So admittedly, he did a grave injustice to zeros, making them the most scarce digit on the board. On the other hand, starting with 1 and ending with 1 in the unit's place gave 1 an edge, making it the most abundant one.
So the most and least abundant digits add up to 1.
The explanation looks really good.
Superb explanation.
Best explanation
That's where my mind was going but didn't reach the destination though. Thanks.
Log in to reply
this is an answer: • yes. a + b is in the x function. But I remember that. Uh. x is not equal to 2 When a = 19. • so. let a = 16 be (89 - 3x)(x - 3)({{10. • (basically. we don't if 0 = 1.) we o know that x = 2 when f to x is equal to 10x. (btw. x = (({{23}}).)
Even without doing the detailed calculations, it is easy to observe that if we consider all the numbers from 1 to 8999, there would be an equal number of 1's, 2's, 3's, ..., 7's and 8's, fewer 9's and much lesser 0's (0 NOT in the leading digits). Even after considering the two left out numbers i.e. 9000 and 9001, 0 would still appear the least of the times and 1 would appear the most of the times. a = 1 and b = 0 ==> a + b = 1 + 0 = 1.
The calculations are given below: Total Number of 0's = {0 + 9 + 2 * (9 * 10) + 3 * (8 * 10 + 10)} + 5 = (0 + 9 + 180 + 2400) + 5 = 2589 + 5 = 2594
Total Number of 1's = [1 + (10 + 9) + {10 * 10 + 2 * (9 * 10)} + {10 * 10 * 10 + 3 * (8 * 10 * 10)}] + 1 = (1 + 19 + 280 + 3400) + 1 = 3700 + 1 = 3701
Total Number of 2's, 3's, ..., 8's = [1 + (10 + 9) + {10 * 10 + 2 * (9 * 10)} + {10 * 10 * 10 + 3 * (8 * 10 * 10)}] = 1 + 19 + 280 + 3400 = 3700
Total Number of 9's = [1 + (10 + 9) + {10 * 10 + 2 * (9 * 10)} + {3 * (8 * 10 * 10)}] + 2 = (1 + 19 + 280 + 2400) + 2 = 2700 + 2 = 2702
From 1 to 99 every number is same no of times....... except one O in the begining
From 100 to 999 also it is same.....
From 1000 to 8999 is also same
So we have 9000 and 9001
9 = 2 times
0 = 3+2-1(at the begining) = 4 times
1 = 1 times
So a = 0 .......... b = 1
Sum = a+b = 1
I did exactly the same thinking. I forgot the first 0 in my try to find the solution but either way 4 or 5 zeros were the highest digit used at numbers 9000 9001 . a = 0 and b = 1 so a + b = 1
This is incorrect, 0 is least used and 1 is most used
I just can't wrap my mind around this, how is it possible that from 1000 to 8999 the digits are equally spread? I mean, we left out all the nine digits we need to count for each 9XXX number but we counted every 8XXX number, 7XXX number and so forth. Some explanation? I know some people think this problem is easy but probably i'm missing something fundamental about the underlying pattern.
1 appears the most because it is up to 9 0 0 1 -- meaning that the "1" appears as a units digit one more time than the rest of the digits 1-9. 0 appears the least because the starting digit cannot be 0 .
Of course we can be more rigorous but it's a multiple choice... like the AMC that often means speed is king.
That's how I did it, I admire the math employed by others but I approached it is a logic problem
0 is the least occurring (obviously), so we just find the most occurring. All the numbers have the same amount of digits (except 9) till 9000. 9001 contains an extra 1, so 1 is the most occurring.
1+0=1
Much simpler answer. Let's look at what happens at each digit.
1st: 1~0 loop + 1 "So it ends with extra 1"
2nd: 1~0 loop
3rd: 1~0 loop
4th: 1~0 loop + 1~9 "My goodness 0 is missing!"
a=1, b=0
a+b = the answer~~!
Definitely underrated answer. Good job!
as Fred is listing between 1 to 9001 ,in wrinting all these the most appearing digit will be 1(you can think it by just supposing integers range from 1 to 20 .in this range 1 appear for 11 times and 0 for 2 times only .by doing this practice u will observe 1 is the most occuring disgit and 0 is the least so sum of 1+0 is 1
That doesn't make sense. You can't apply patterns from 1 to 20 to 1 to 9001 without justification
1-8 digit would be same in numbers till 9000. Then for 9001, 1 becomes highest in number 0 will always be less than other 9 digits in numbers as it never appears as the digit in most significant place.
For numbers from 1 - 9000, the first digit can be 1-9, second, third and fourth digits are also 0-9. This means 1-9 appears equal times. Since it ends at 9001, there is an extra 1.
fred listed integers from 1 to 9001.. the most used digit is zero... because in thousands 3 or 2 zeros are used. eg: in thosand, 1000 three zeros are used and in 1001,1002,1003,.... 2 zeros are used! therefore the dgit he wrote the most 'a'= 0 , and the digit he wrote the least is 1,, because he wrote integers upto 9001... not 10000,10,001... therefore 'b'=1,,, now a+b=0+1=1
It's not true 0 is the most used. It's exactly the opposite but you are really lucky to get the answer with wrong logic :).
wow.. nicely solved
nice concept
Totally wrong concept... a= 1 and b=0 it should be.... :)
wat abt 11, 111, 1111, 1011, 1001, 1101, 101, 2111,3111........8111 and so many others with 1 in them and zero it can't be 0000,00,000 it has to come in the number after the first digit so there are more 1s than 0s. Anyways nice try my frnd:)
totally wrong and absurd as 0 as not written as prefix as 0001 and else all conditions are same for all digits but 1 is most used due to starting from 1 and ending up at 9001
1 to 9001 = 9001. 9001 = 9000+1 = a+b= 9000+(1). 1 is the correct answer.
digit 1 appears the most and digit 0 appears the least number of times from 1 to 9001. for example: from 1 to 101; digit 1 appears 23 times and digit 0 appears 12 times and the rest digit appears less than 23 times and more than 12 times. So, a is 1 and b is 0 hence a+b=1+0=1
I didn't even see the problem when I solved this. I thought it was asking for the digit that appears the most in the picture and I saw 1. LOL!
Most frequent digit ->0(a) [ By educated guess or intuition] Least frequent digit-> 1(b) [ same as above] a+b= 1
0 occurs least as 1-100 are not written as 001,002 etc. till 9000 digits 1-8 occurs same. therefore by 9001 , digit 1 occurs once again.
Because 1 appears more than any digit, for the sequence starts and ends with 1 as a digit, it must be a. Since no number will start with 0, it is the least used and is b.
1+0=1.
x 10
20
30 . . . . . . . 90 100
1 11
21
31 . . . . . . . 91
2
12
22
32
. . . . . . .
92
3 . . . . . . . . . . . . . . . .
: :
: :
9 19
29
39 . . . . . . . .99
>no of 2's are - 20
>no of 3's, 4's ....9's are 20 .
>no of 1's = 20 + 1(from 100) = 21
>no of 0's = 9 + 2 (from 100) = 11
>this is the case from 1 to 100 , similarly the numbers are in the same ratios from 1 to 9000 plus we are getting an additional " 1 " from 9001.
>so a = 1 and b = 0
1 to 99 =20 100 to 199 =120 200 to 299 =20 300 to 399 =20 400 to 499 =20 500 to 599 =20 600 to 699 =20 ...................( my hand is cramping :( 900 to 999 =20 1000 = 1 total=301
so, from 1 to 1000: digit '1' appears 301 times.
Therefore 1 to 9001 digit '1' appears more times than other digits
From 1 to 9, 11 to 99, 111 to 999, 1111 to 9999 all the digit appear at the same quantity. But 0 and 1 are still appear in 10, 100, 1000. And 9999 decrease to 9001, all the digit from 2 to 9 decrease at the same quantity except 0 and 1 decrease fewer. So the answes is 1+0=1
when writing a set of 100 integers starting with one, you write every digit exactly the same number of times as the other except zero. so, obviously no matter how much integers you write, you will write zero the least number of times. hence we have our value b=0.
now "a". consider the set of hundred integers i mentioned above. every digit will be written 20 times in it. expanding this set to a 1000 integers we write the numbers 1-100 with 1,2,3.....and 9 in front of them. like, 100 ones in 100-199 100 twos in 200-299 . . . . 100 nines in 900-999
a little consideration with this result, we understand that we write the digits 1-9 the same number of times no matter how many numbers we write, provided we finish at a thousand or million and so on.
here in our problem fred has written till 9001, one more than a thousand. so the only digit written the most is "1". it has been written one more time than the digits 2-8.
so a=1.
now we get a+b=1.
NOTE: in this problem, 9 is not written the same number of times as the digits 2-8 because, the numbers 9002-9999 are not written, anyway zero is written fewer number of times than nine. here we need not worry about it.
b=0, and since he wrote till 9001 a =1
Problem Loading...
Note Loading...
Set Loading...
One is the digit that appears the most as each number appears an equal amount of times e.g teens, twenties, etc. However as the final number is 9001, the extra one causes one to be the most occurring. Zero is the least occurring as zero is always after another number, never before. So A=1 B=0 , therefore 1+0 =1