The sum of the digits 0-9 is 45 and 4+5 is 9 so any number containing the
digits 0-9 exactly once is going to be divisible by 9, and hence will not be
prime.  

You're going to have to look for pandigital numbers containing repeated
digits, that is N > 9876543210 .  So you can skip the permutation
calculation.  Also, without proof, I speculate there will be no largest
pandigital prime.

J has a built in primality test:  primeTest =: 1&p:  .  This is
deterministic for small N and probablistic for large N.

-Dan

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of David Vaughan
Sent: Friday, July 08, 2011 6:54 AM
To: Programming forum
Subject: Re: [Jprogramming] Checking permutations

I'm trying to find the highest 1-9 pandigital prime, so I need to get the
permutations in reverse order if possible. Also, how can I apply my
primeTest script to the results?

   primeTest =: 3 : 'if. #@:q:y do. y end. '
This is what I have so far. The rank of y and of the list of permutations
don't match up, and it feels like my 'if.' approach isnt great.

Can anyone offer any advice as to how achieve this?

Thanks. 

___________________________

David Vaughan

On 8 Jul 2011, at 11:29, Ric Sherlock <[email protected]> wrote:

> (i.@!@# A. ]) 'abcd'
>  or
> (A.~ i.@!@#) 'abcd'
> 
> see also:
> http://rosettacode.org/wiki/Find_the_missing_permutation#J
> 
> On Fri, Jul 8, 2011 at 9:44 PM, David Vaughan
> <[email protected]> wrote:
>> 
>> How would you go about getting all the permutations of a string in J?
>> ___________________________
>> 
>> David Vaughan
>> ----------------------------------------------------------------------
>> For information about J forums see http://www.jsoftware.com/forums.htm
>> 
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to