Which Digit Appears The Most?

Algebra Level 2

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 a , and the digit that he wrote the least be b b . Find a + b a+b .

five ten one nine

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.

26 solutions

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

Can you show that 0 doesn't occur as much as 9? (The main difficulty of the problem)

minimario minimario - 7 years, 4 months ago

Log in to reply

What makes it so difficult? 9 9 appears as a hundreds digit of a three digit number and tens digit of a two digit number 110 times. 0 0 appears as such none of the time.

Michael Tong - 7 years, 4 months ago

Log in to reply

I don't understand why this problem is rated 2057, either.

minimario minimario - 7 years, 4 months ago

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 1 until 9 9 excluding the 0 0 digit (I almost answered TEN!).

Ammar Fathin Sabili - 7 years, 4 months ago

Log in to reply

@Ammar Fathin Sabili yeah that exactly what happened to me

Vikram Pandya - 7 years, 4 months ago

@Ammar Fathin Sabili Me 'two'! (Plus, the rating for me was 2001)

Eric Hernandez - 7 years, 4 months ago

@Ammar Fathin Sabili I did the same :D

Sara Askar - 6 years, 4 months ago

@Ammar Fathin Sabili I did answer 10, just because I didn't stop to consider 0.

Jim Clemens - 5 years, 1 month ago

Why 110 Times?

Elias Adler - 4 years, 10 months ago

subscribe to pewdiepie and help youtube.com live

KC Yao - 2 years, 5 months ago

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.

Emily Peng - 1 year, 6 months ago

Did n"t seem to be level 5th question.

Prasad Nikam - 7 years, 4 months ago

0 confused as much as 9 .

Irfan Ali - 7 years, 4 months ago

Same I don't understand why it's rated so high either....the problem is quite trivial imo. took me <10s =.=

Muhammad Shariq - 7 years, 4 months ago

Log in to reply

Exactly, the answer was pretty obvious. It isn't simply challenging enough to be a level 5 question.

Aditya Bhattacharya - 7 years, 4 months ago

as 0 after 10 ,20 30 etc it will come 890 times whereas 9 will come 891 times 1 more as in 9001.....

Gurjot Sodhi - 6 years, 8 months ago

Log in to reply

subscribe to pewdiepie and help youtube.com live and stay alive

KC Yao - 2 years, 5 months ago

fifth level seems some hard

vinay kumar - 7 years, 4 months ago

i forget the 0...

Valerian Pratama - 7 years, 4 months ago

I do not understand how people got one as the answer. Can someone please explain this to me?

Celeste Carrasco - 5 years ago

I used the same technique... It was quite simple 😏

Ishan Maheshwari - 4 years, 7 months ago

I don’t understand To be honest I just guessed

Joash Ong - 5 months, 3 weeks ago

The real question is who would do that when they are bored.

Ethan Tran - 1 month, 2 weeks ago

I forgot the zero.........

Arpit Kharbanda - 7 years, 3 months ago
Petko Petkov
Jan 20, 2014

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:

  1. from 1 to 9 it's 0
  2. from 10 to 99 it's 9
  3. from 100 to 999 it's 9 × \times 20 (for each 1XX, 2XX, ..., 9XX) + 9 (from point 2)) = 189
  4. from 1000 to 9999 it's 9 × \times 300 (for each 1XXX, 2XXX, ..., 9XXX) + 189 (from point 3)) = 2889

So, finally M=2889.

Now we have to remove the digits from the sequence 9002-9999. We have:

  • for 1: N - 300 (for 9XXX) + 1 (for 9001) = 4000 - 300 + 1 = 3701
  • for each 2,3,..., 8: N - 300 (for 9XXX) = 4000 - 300 = 3700
  • for 9: N - 1300 (for 9XXX) + 2 (for 9000 and 9001) = 4000 - 1300 + 2 = 2702
  • for 0: M - 300 (for 9XXX) + 3 (for 9000) + 2 (for 9001) = 2889 - 300 + 3 + 2 = 2594

Finally, 1 is used 3701 \boxed{3701} times (max value) and 0 is used 2594 \boxed{2594} times (min value) which makes a = 1 \boxed{a=1} and b = 0 \boxed{b=0} so a + b = 1 \boxed{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

Rajesh Paul - 7 years, 4 months ago

Beautiful!

Anas Masood - 7 years, 4 months ago

brilliant

Long Phạm Sơn - 7 years, 4 months ago

brilliant

Putri Lestari - 7 years, 4 months ago

Brilliant

Punsisi Bandara Kiridana - 7 years, 4 months ago

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;
        }
    }
}

}

Bashirul Islam Sheikh - 7 years, 4 months ago

We can also look at it from any range of the form 0 to 99999...

Here is the pattern

0 to 0 (Initial condition)

  • Digits[1,9] occurs: 0
  • Digits[0] occurs: 1

0 to 9 (Magnitude 1)

  • Digits[1,9] occurs: 1 + 0 * 10 = 1
  • Digits[0] occurs: 0 + 0 * 9 + 1 = 1 (separation will make more sense later)

0 to 99 (Magnitude 2)

  • Digits[1,9] occurs: 10 + 1 * 10 = 20
  • Digits[0] occurs: 0 + 1 * 9 + 1 = 10 (separation will make more sense later)

10 vs 0

  • 10 is for the padding of the "new" digit
    • 10,11,12,...,19
  • 0 cannot be the left most digit; there is no zero padding by convention
    • 01,02,03,...,09

1 * 10 vs 1 * 9 + 10

  • 1 is from 0 to 9 multiplied by the times they occur, 10

1 * 9 + 1

  • There is zero "padding" now, excluding the most significant digit as in 10,20,30,...,90 (similar concept to actual padding later)
  • However, this only occurs 9 times for 10 to 99 since 00 does not follow convention. (the tens digit 0)
  • This would mean the 1 from the previous result occurs 9 times to get 1 * 9 from 10 to 99 and 1 from 0 to 9 => 1 * 9 + 1

0 to 999 (Magnitude 3)

  • Digits[1,9] occurs: 100 + 20 * 10 = 300
  • Digits[0] occurs: 0 + 20 * 9 + 10 = 190 (separation should start making sense)

100 vs 0

  • 100 is for the padding of the "new" digit
    • 100,101,102,...,199
  • 0 cannot be the left most digit; there is no zero padding by convention
    • 001,002,003,...,099

20 * 10 vs 20 * 9 + 10

  • 20 is from 0 to 99 multiplied by the times they occur, 10

20 * 9 + 10

  • There is zero padding now, excluding the most significant digit as in 101,102,103,...,109
  • However, this only occurs 9 times for 100 to 999 since 001,002,003,...,009 does not follow convention.
  • This would mean the 10 from the previous result will be 20 instead to get 20 * 9 from 100 to 999 and 10 from 0 to 99 => 20 * 9 + 10

0 to 9999 (Magnitude 4)

  • Digits[1,9] occurs: 1000 + 300 * 10 = 4000
  • Digits[0] occurs: 0 + 300 * 9 + 190 = 2890 (separation should make sense)

1000 vs 0

  • 1000 is for the padding of the "new" digit
    • 1000,1001,1002,...,1999
  • 0 cannot be the left most digit; there is no zero padding by convention
    • 0001,0002,0003,...,0999

300 * 10 vs 300 * 9 + 190

  • 300 is from 0 to 999 multiplied by the times they occur, 10

300 * 9 + 190

  • There is zero padding now, excluding the most significant digit as in 1001,1002,1003,...,1099
  • However, this only occurs 9 times for 1000 to 9999 since 0001,0002,003,...,0099 does not follow convention.
  • This would mean the 190 from the previous result will be 300 instead to get 300 * 9 from 1000 to 9999 and 190 from 0 to 999 => 300 * 9 + 190

and so on...

0 to 999... (Magnitude n; n is the number of 9's)

  • Digits[1,9] occurs: 10^(n-1)+ Count [ n-1 ] (D[1,9]) * 10 = Count [ n ] (D[1,9])
  • Digits[0] occurs: 0 + Count [ n-1 ] (D[1,9]) * 9 + Count [ n-1 ] (D[0]) = Count [ n ] (D[0])

For the actual problem

1 to 9001

  1. 0 to 999
    • Digits[1,9] occurs: 100 + 20 * 10 = 300
    • Digits[0] occurs: 0 + 20 * 9 + 10 = 190
  2. 0 to 9999
    • Digits[1,9] occurs: 1000 + 300 * 10 = 4000
    • Digits[0] occurs: 0 + 300 * 9 + 190 = 2890
  3. Starting at 1 instead of 0 and ending at 9001
    • Digits[2,8] = 4000 - 300 = 3700
      • -300 => 1 less 0 to 999 occurrence, specifically 9000 to 9999
    • Digits[9] = 4000 - 300 + 2 = 3702
      • -300 => 1 less 0 to 999 occurrence, specifically 9000 to 9999
      • +2 => 9000, 9001
    • Digits[1] = 4000 - 300 + 1 = 3701
      • -300 => 1 less 0 to 999 occurrence, specifically 9000 to 9999
      • +1 => 9001
    • Digits[0] = 2890 - 300 + 2 + 2 + 1 - 1 = 2594
      • -300 => 1 less 1000 to 9999 occurrence, specifically 9000 to 9999
      • +2 => 9000, 9001 contributes 2 zeroes at the hundreds digit (0 to 9999 "new" zero padding)
      • +2 => 9000, 9001 contributes 2 zeroes at the tens digit (0 to 999 "new" zero padding)
      • +1 => 9000 contributes 1 zero at the ones digit (0 to 99 "new" zero "padding")
        • 10,20,30,..,90
      • -1 => Starting from 1 not 0

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.

Flewk Isdead - 6 years, 9 months ago

Log in to reply

Wow great explanation

Joash Ong - 5 months, 3 weeks ago

Can Someone explain to me why N = 4000?

Elias Adler - 4 years, 10 months ago

Petro you must have a lot of time on your hand

Joe Zientara - 3 years, 9 months ago

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)

Aun Abbas Jaffery - 7 years, 4 months ago

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.

Petko Petkov - 7 years, 4 months ago
Arnab Acharya
Jan 21, 2014

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.

Rajesh Paul - 7 years, 4 months ago

Superb explanation.

Anbu Ganesan - 7 years, 4 months ago

Best explanation

Flewk Isdead - 6 years, 9 months ago

That's where my mind was going but didn't reach the destination though. Thanks.

Raisa Zaman - 3 weeks, 3 days ago

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}}).)

Am Kemplin - 10 hours ago
Shamik Banerjee
Jan 20, 2014

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

Anand Raj
Feb 3, 2014

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

Panagiotis Tamis - 6 years, 9 months ago

This is incorrect, 0 is least used and 1 is most used

Edward Verlie - 4 years, 6 months ago

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.

Michele Franzoni - 1 year, 11 months ago
Michael Tong
Jan 20, 2014

1 1 appears the most because it is up to 9001 9001 -- meaning that the "1" appears as a units digit one more time than the rest of the digits 1-9. 0 0 appears the least because the starting digit cannot be 0 0 .

Of course we can be more rigorous but it's a multiple choice... like the AMC that often means speed is king.

Michael Tong - 7 years, 4 months ago

That's how I did it, I admire the math employed by others but I approached it is a logic problem

Edward Verlie - 4 years, 6 months ago

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

Yoon Ho Seol
Apr 10, 2016

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!

Michele Franzoni - 1 year, 11 months ago
Abid Bashir
Jan 22, 2014

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

Flewk Isdead - 6 years, 9 months ago
Ashish Kumar
Jan 21, 2014

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.

  1. 2 digits - [1-9][0-9]
  2. 3 digits - [1-9][0-9][0-9]
  3. 4 digits - [1-9][0-9][0-9][0-9]
Ng Donn
Jan 21, 2014

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.

Hafsa Murtaza
Jan 18, 2014

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 :).

Petko Petkov - 7 years, 4 months ago

wow.. nicely solved

SUCHITRA MOHANTY - 7 years, 4 months ago

Log in to reply

Thanks for appreciating :)

Hafsa Murtaza - 7 years, 4 months ago

nice concept

Anuradha Sen - 7 years, 4 months ago

Totally wrong concept... a= 1 and b=0 it should be.... :)

Anik Bhattacharjee - 7 years, 4 months ago

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:)

mukul singla - 7 years, 4 months ago

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

Ashutosh Kumar - 7 years, 4 months ago
Jenson Chong
Dec 10, 2020

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

Jack Mamati
Aug 20, 2014

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!

Bilal Muhammad
Mar 3, 2014

1

D K
Feb 23, 2014

Most frequent digit ->0(a) [ By educated guess or intuition] Least frequent digit-> 1(b) [ same as above] a+b= 1

Akhilesh P
Feb 3, 2014

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.

Junlin Yi
Jan 28, 2014

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.

Vinod Kumar
Jan 25, 2014

1+0

Venkatesh Durga
Jan 25, 2014

1

Himanshu Sharma
Jan 25, 2014

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




Venkata Mahesh
Jan 24, 2014

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

Võ Trọng
Jan 22, 2014

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.

Karan Mirani
Jan 20, 2014

b=0, and since he wrote till 9001 a =1

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...