jQuery in Action, 2nd edition
The moose likes Java in General and the fly likes truncatable prime numbers Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "truncatable prime numbers" Watch "truncatable prime numbers" New topic
Author

truncatable prime numbers

Sam Benry
Ranch Hand

Joined: Mar 21, 2008
Posts: 89
I have this question from euler

The number 3797 has an interesting property. Being prime itself, it is possible to continuously remove digits from left to right, and remain prime at each stage: 3797, 797, 97, and 7. Similarly we can work from right to left: 3797, 379, 37, and 3.

Find the sum of the only eleven primes that are both truncatable from left to right and right to left.

NOTE: 2, 3, 5, and 7 are not considered to be truncatable primes.


I can't figure out the eleven prime numbers, why are these prime numbers wrong:
11
13
17
23
31
37
53
71
73
113
131

aren't they all truncatable from both left and right? and if they are, there are still many more truncatable prime numbers from both left and right... what am I doing wrong?
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 16483
    
    2

1 isn't a prime number, so that rules out many of the numbers in your list.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: truncatable prime numbers
 
Similar Threads
Sieve of Eratosthenes
Prime Factor Program
project euler
Finding the largest Prime Factor
Left Truncatable Primes Java Program