Left-Truncatable Primes


A left-truncatable prime is a prime number (without the digit zero) that when you remove any of its left most decimal digit, it still represents a prime number (or no number at all if you remove all of the digits). 5167 is a left-truncatable because 5167, 167, 67, and 7 are all prime.

Notes from my UBASIC program LEFT-TU.UB:

10 ' Start of file Left-Tru.UB Left-truncatable primes in UBASIC 20 ' 30 word -10:cls:print 40 print " Left-Tru.UB - Computes all left-truncatable primes (LTP)" 50 print " Version 1.10, last revised: 2007-11-13" 60 print " Copyright (c) 1981-2007 by author: Harry J. Smith," 70 print " 19628 Via Monte Dr., Saratoga CA 95070. All rights reserved." 80 print 90 print " Quote from WEB page" 100 print " www.utm.edu/research/primes/glossary/LeftTruncatablePrime.html" 110 print 120 print " 'Left-truncatable primes (or just truncatable primes) are" 130 print " prime numbers (without the digit zero) that remain prime no" 140 print " matter how many of the leading digits are omitted. For" 150 print " example, 4632647 is left-truncatable because it and each of" 160 print " its truncations: 632647, 32647, 2647, 647, 47, and 7 are" 170 print " prime. We omit the digit zero to avoid trivial examples such" 180 print " as the prime 10^60+7:" 190 print 200 print " 1000000000000000000000000000000000000000000000000000000000007." 210 print 220 print " Each of its truncations is the prime 7.'" 230 print 240 print " Will write file Left-Tru.OUT" 250 strinput " Do you wish to continue (Y/N) :";S$ 260 if (S$<>"Y") and (S$<>"y") then end 270 print 280 ' 290 ' Computes all left-truncatable primes and outputs to file Left-Tru.Out 300 '

PARI code for thia as On-Line Encyclopedia of Integer Sequences! sequences A132394:

{ fileO="b132394.txt"; v=vector(4260); v[1]=2; v[2]=3; v[3]=5; v[4]=7; i=0; j=4; write(fileO, "1 2"); write(fileO, "2 3"); write(fileO, "3 5"); write(fileO, "4 7"); until (i>=j, i++; p=v[i]; P10=10^(1 + log(p)\log(10)); for (k=1, 9, z=k*P10+p; if (isprime(z), j++; v[j]=z; write(fileO, j, " ", z); ) ) ); }

Return to Number Theory, Algorithms, and Real Functions
Return to Harry's Home Page


This page accessed times since September 16, 2008.
Page created by: hjsmithh@sbcglobal.net
Changes last made on Wednesday, 08-Oct-08 16:00:37 PDT