Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

How to find largest pandigital prime number ?

by perlCrazy (Monk)
on Jul 23, 2010 at 09:16 UTC ( #850995=perlquestion: print w/ replies, xml ) Need Help??
perlCrazy has asked for the wisdom of the Perl Monks concerning the following question:

want to write function that will return largest pandigital prime number based on passed parameter.
 findLargest($numberOfDigits)
Can somebody point me in right direction or suggest some algorithm in perl so that I can call finction and return pandigital number.
Thanks for help in advance.

Comment on How to find largest pandigital prime number ?
Download Code
Re: How to find largest pandigital prime number ?
by Anonymous Monk on Jul 23, 2010 at 09:29 UTC
Re: How to find largest pandigital prime number ?
by moritz (Cardinal) on Jul 23, 2010 at 09:57 UTC
    For base 10, the largest pandigital number of length 10 is 9876543210. You can successively create smaller pandigital numbers from that, and test them for primeness.

    Algorithm::Loops or Algorithm::Permute might help you creating the numbers.

    Somhow this looks like a project euler task to me - isn't it more fun to solve them on your own?

    Perl 6 - links to (nearly) everything that is Perl 6.
      For base 10, the largest pandigital number of length 10 is 9876543210.
      No 10 digit pandigital number is prime (the sum of their digits is 45, so they're all divisible by 3).
      You can successively create smaller pandigital numbers from that, and test them for primeness.
      Pointless. The smallest pandigital prime is 10123457689. (Sloane A050288)
Re: How to find largest pandigital prime number ?
by JavaFan (Canon) on Jul 23, 2010 at 11:56 UTC
    want to write function that will return largest pandigital prime number based on passed parameter
    That's a tall order. My first instinct would be to browse on the internet, and see whether someone already has a list. I don't find such a list on Sloane. It does have an entry for Pandigital primes, with some Mathematica code to generate them. But you'll have to generate millions of them to even get to the smallest number findLargest can return.

    If I were to calculate them in Perl, I'd use PDL.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://850995]
Approved by planetscape
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (8)
As of 2014-08-23 12:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (173 votes), past polls