

The following problem appeared as ENIGMA 1168 in New Scientist 5 January 2002
THRICE UNFACTORISEDRichard EnglandI have found a fourdigit number such that it is impossible to factorise the numbers formed by its first digit or last digit or first two digits or middle two digits or last two digits or first three digits or last three digits or all four digits. In other words all those eight numbers are prime except that either or both of the singledigit numbers may be unity. Harry and Tom have also found such a fourdigit number. The fourdigit numbers that we have found are all different; but Harry's number uses the same digits as Tom's number, though in a different order. Which fourdigit number have I found? 
We might use SQL to generate prime numbers  but it's easier and quicker to get some from elsewhere such as James Edwards at Bristol or Chris Caldwell at the University of Tennessee.
The table prime contains the 1300 small primes including all the four digit primes.
1  Check that the tables primes exists by viewing all primes less than 50. 

2  The SUBSTR function in Oracle may be used to extract digits. 
