Left Truncatable Prime

   
Recent changes
Table of contents
Links to this page
FRONT PAGE / INDEX

Subscribe!
@ColinTheMathmo

My latest posts can be found here:
Previous blog posts:
Additionally, some earlier writings:

2017/10/21 - Left Truncatable Prime

Recently Maths Inspiration produced some pencils with a fantastic idea. Yes, their name is on it:

https://www.solipsys.co.uk/images/MathsInspirationPencil.jpg

Yes, it has a slightly cheesy catch-phrase:

https://www.solipsys.co.uk/images/MathsInspirationPencil_Logo.jpg

But then there is something really clever.

I've had some more information about this, and the true story[0] is even better than I thought. Apparently the actual text was "Too Cool to do Drugs" - so that was:
  • TOO COOL TO DO DRUGS
  • then: COOL TO DO DRUGS
  • and then we get: DO DRUGS
Someone has even done a remake of the pencil[1].

My thanks to Stratoscope[2] for the comment[3] on Hacker News[4].

There was a beautiful and now classic example of a marketing fail when someone produced a pencil with the logo "DON'T DO DRUGS". But as the pencil was sharpened the logo was gradually reduced, firstly to the direct exhortation "DO DRUGS" and then finally the simple, dramatic, "DRUGS".

Similarly, then, the prime printed on the Maths Inspiration pencil will, of course, be reduced from the left as the pencil is used and sharpened, but a wonderful thing happens. As the digits are removed from the left, the number that remains is still prime.

https://www.solipsys.co.uk/images/MathsInspirationPencil_Prime.jpg

It's a left-truncatable prime, which is "A Thing" and you can look it up on the web, but I thought I'd write a quick program to check the one given on the pencil (yes, it's prime), and to see if there was a longer one.

There isn't.

Here's my code. It's intended to be clear rather than clever, but do feel free to tell me what I've got wrong.

Nice challenge: Find a false positive from this prime testing routine.

 
  #!/usr/bin/python

  from math import log

  small_primes = [ 2, 3, 5, 7, \
                   11, 13, 17, \
                   19, 23, 29, ]

  def is_prime( n ):

      if n in small_primes: return True
      if n < small_primes[-1]: return False

      for p in small_primes:
          if pow(p,n-1,n)!=1:
              return False
      return True

  limit = 10
  prospects = range(2,limit)

  prospects = [ x for x in prospects if is_prime(x) ]

  while prospects:

      p2 = []
      for t in range(1,10):
          p2 += [ t*limit+x for x in prospects \
                      if is_prime( t*limit+x ) ]
      prospects = p2
      limit *= 10
      print log(limit)/log(10), len(prospects), prospects

Lovely thing.


References:


<<<< Prev <<<<
The Doctor And The Lawyer
:
>>>> Next >>>>
Not A Spectator Sport ...


https://mathstodon.xyz/@ColinTheMathmo You can follow me on Mathstodon.



Of course, you can also
follow me on twitter:

@ColinTheMathmo


Send us a comment ...

You can send us a message here. It doesn't get published, it just sends us an email, and is an easy way to ask any questions, or make any comments, without having to send a separate email. So just fill in the boxes and then

Your name :
Email :
Message :


Contents

 

Links on this page

 
Site hosted by Colin and Rachel Wright:
  • Maths, Design, Juggling, Computing,
  • Embroidery, Proof-reading,
  • and other clever stuff.

Suggest a change ( <-- What does this mean?) / Send me email
Front Page / All pages by date / Site overview / Top of page

Universally Browser Friendly     Quotation from
Tim Berners-Lee
    Valid HTML 3.2!