Left Truncatable Prime 


My latest posts can be found here: Previous blog posts:
Additionally, some earlier writings: 
2017/10/21  Left Truncatable PrimeRecently Maths Inspiration produced some pencils with a fantastic idea. Yes, their name is on it:
Yes, it has a slightly cheesy catchphrase:
But then there is something really clever.
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.
It's a lefttruncatable 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.
#!/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,n1,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:
Send us a comment ...

Quotation from Tim BernersLee 