All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > Numbers
Long chain (Posted on 2015-04-10) Difficulty: 3 of 5
Create a chain of consecutive digits starting with 1 and following 9 by 0: 123456789012345...

How many digits are needed to obtain the 1st prime number?

See The Solution Submitted by Ady TZIDON    
No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution lesson learned | Comment 6 of 7 |
(In reply to computer exploration by Charlie)

The idiosyncrasies of UBASIC(that I knew about, but didn't think about):


The UBASIC builtin function prmdiv returns a zero when the smallest prime divisor of the argument passed to it is too large for it to handle. That in fact is why I had added the probabilistic prime test. However, I neglected to change the preface "if p>1" that had been added previously, as UBASIC erroneously reports the largest prime divisor of 1 as being 1, which of course is not prime.

In line 70, I should have had "if v>1" rather than "if p>1" as p was the prmdiv that UBASIC returned and v was the value of the whole number.

With that replacement and removal of the stop after finding one, the first three primes found are:

 1234567890123456789012345678901234567890123456789012345678901234567890123456789
01234567890123456789012345678901234567890123456789012345678901234567890123456789
012345678901
length 171

 1234567890123456789012345678901234567890123456789012345678901234567890123456789
01234567890123456789012345678901234567890123456789012345678901234567890123456789
01234567890123456789012345678901234567890123456789012345678901234567890123456789
01234567890123456789012345678901234567
length 277

 1234567890123456789012345678901234567890123456789012345678901234567890123456789
01234567890123456789012345678901234567890123456789012345678901234567890123456789
01234567890123456789012345678901234567890123456789012345678901234567890123456789
01234567890123456789012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567
length 367

Edited on April 11, 2015, 8:40 am
  Posted by Charlie on 2015-04-11 08:32:42

Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (13)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information