Anaprimes

Revision as of 00:59, 1 February 2023 by Thundergnat (talk | contribs) (caveat)

Anaprimes are prime numbers that are anagrams of each other; i.e. they use all of the same digits but in a different order.

Anaprimes is a draft programming task. It is not yet considered ready to be promoted as a complete task, for reasons that should be found in its talk page.

Anaprimes are very common. There is an anagram group however, in each order of magnitude greater than two, that contains more members than any other.


Task
  • Find prime numbers that are anagrams of each other.
  • Find the largest anagram group of prime numbers and display the count, and minimum and maximum members for prime numbers:
    • up to three digits long (before 1,000)
    • up to four digits long (before 10,000)
    • up to five digits long (before 100,000)
    • up to six digits long (before 1,000,000)


Stretch
  • Find the largest anagram group and display the count, and smallest and largest members for prime numbers:
    • up to seven digits long (before 10,000,000)
    • up to eight digits long (before 100,000,000)
    • up to nine digits long (before 1,000,000,000)
    • ???!


Related tasks


Raku

9 digit is slooow. I didn't have the patience for 10.

use Lingua::EN::Numbers;
use Math::Primesieve;

my $p = Math::Primesieve.new;

for 3 .. 9 {
    my $largest = $p.primes(10**($_-1), 10**$_).classify(*.comb.sort.join).max(+*.value).value;

    put "\nLargest group of anaprimes before {cardinal 10 ** $_}: {+$largest} members.";
    put 'First: ', ' Last: ' Z~ $largest[0, *-1];
}
Output:
Largest group of anaprimes before one thousand: 4 members.
First: 179  Last: 971

Largest group of anaprimes before ten thousand: 11 members.
First: 1237  Last: 7321

Largest group of anaprimes before one hundred thousand: 39 members.
First: 13789  Last: 98731

Largest group of anaprimes before one million: 148 members.
First: 123479  Last: 974213

Largest group of anaprimes before ten million: 731 members.
First: 1235789  Last: 9875321

Largest group of anaprimes before one hundred million: 4,333 members.
First: 12345769  Last: 97654321

Largest group of anaprimes before one billion: 26,519 members.
First: 102345697  Last: 976542103