The Persistent Digit

Integers from 1 to 2016 are joined in a string S S :

S = 123456789 201420152016 S=123456789\ldots 201420152016

Which digit appears the most?


The answer is 1.

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.

4 solutions

Serkan Muhcu
May 15, 2016

I can't find the mistake in my solution:

From 0000 to 0999 every digit appears in the same amount, and since the zeros that appear as the first digit of a number aren't written, there are even less zeros than the other digits. From 1000 to 1999 the digits appear in the same amount as the last three digits, with the expection that 1 appears additional 1000 times. The digits in the numbers between 2000 and 2016 can be disregarded. Therefore, 1 must appear mostly in S.

Sorry for my bad english by the way

Thanks. Those who answered 1 have been marked correct.

In future, if you spot any errors with a problem, you can “report” it by selecting "report problem" in the menu. This will notify the problem creator who can fix the issues.

Calvin Lin Staff - 5 years ago

You are right !! @Paola Ramírez I think you should recheck the solution .......

Parth Bhardwaj - 5 years, 1 month ago

I also thought 1 but as we go up from 1000 ownwards you see the number of times 0 comes is multiplied and 0 then becomes a regular occurrence, 1001,1022, 1100, 1101, 2000, 2001......

Nishant Sood - 5 years, 1 month ago

Log in to reply

That's not true. After 1000 it appears an extra 100 + 10 times (hundreds digits + tens digit). Meanwhile, 1 appears an extra 1,000 times. I agree with Serkan.

Alex Li - 5 years, 1 month ago
Orko Sinha
May 17, 2016

The answer is 1, because I think Bedford's Law applies

I'd love to hear Calvin's comment on this. If it helps, I applied Benford's Law as a first guess.

Tamojit Maiti - 5 years ago
Arcane Spirits
May 16, 2016

I have written a bit of code that ran through each number from 1 up to 2016 and counted each number that occured. Here are the results: 0: 518

1: 1609

2: 619

3: 602

4: 602

5: 602

6: 602

7: 601

8: 601

9: 601

To check my results, I added all the numbers to one string, and the length of this was 6957. The sum of all the occurances also equals 6957.

The results are pretty logical since numbers between 1000 and 1999 all share 1 number: the 1 at the front. As Serkan has stated, from 000 to 999 all the numbers occur the same amount of time. This means that 1 will occur 1000 times more than the others.

There are less 0s because the first digits (below 1000) don't have a 0 at the front to fill the space with, as we normally don't write them either.

There will also be 17 more 2s, since we also add 17 numbers in 2000. (2000 up to 2016) Here's also where the additional 3, 4, 5 and 6 come in, as well as even more 1s.

Conclusion: the correct answer should definitely be 1.

As for those wondering, I wrote my code in VS2015 using C++, because I am still in the learning phase of programming and C++ is all I know so far.

The code here uses my school's engine, which uses a slightly modified version of strings and so on, however, it should not have affected the results.

What I did was the following:

  • Find the number at position 0 (i.e. in 2016, the number at the first position is 2).

  • In an array which keeps track of how many times each number occured, add 1 to "2"

  • Get the substring from position 1 until the end (i.e. in a string "2016", the substring will be " 016")

  • Continue step 1-3 until the length of the substring is 0.

  • Get the next number

  • Make this number into a string.

  • Repeat from beginning until the next number is 2017.

Answer is 1. However, Briliant shows that 0 is a correct answer.

Alex Gawkins - 5 years, 1 month ago

Log in to reply

1 appears the most in this string. 0 only appears about 500 times were all the other digits should appear about 600 time but 1 would be over 1000.

Anthony Musicdude Reyes - 5 years, 1 month ago

Thanks. Those who answered 1 have been marked correct.

In future, if you spot any errors with a problem, you can “report” it by selecting "report problem" in the menu. This will notify the problem creator who can fix the issues.

Calvin Lin Staff - 5 years ago
Masbahul Islam
Jun 14, 2016

0: 518

1: 1609

2: 619

3: 602

4: 602

5: 602

6: 602

7: 601

8: 601

9: 601

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...