Truncatable primes: Difference between revisions

Content added Content deleted
Line 826: Line 826:
step=: selPrime@,@:(,&.":/&>)@{@;</lang>
step=: selPrime@,@:(,&.":/&>)@{@;</lang>


Here, selPrime discards non-prime numbers from a list, so seed is the list 2 3 5 7.
The largest truncatable primes less than a million can be obtained by adding five digits to the prime seeds, then finding the largest value from the result:

The largest truncatable primes less than a million can be obtained by adding five digits to the prime seeds, then finding the largest value from the result.


<lang j> >./ digits&step^:5 seed NB. left truncatable
<lang j> >./ digits&step^:5 seed NB. left truncatable
Line 832: Line 834:
>./ step&digits^:5 seed NB. right truncatable
>./ step&digits^:5 seed NB. right truncatable
739399</lang>
739399</lang>

Note that we are using the same combining function and same basic procedure in both cases. The difference is which side of the number we add arbitrary digits to, for each step.


=={{header|Java}}==
=={{header|Java}}==