The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Math::NumSeq::ErdosSelfridgeClass -- Erdos-Selfridge classification of primes

SYNOPSIS

 use Math::NumSeq::ErdosSelfridgeClass;
 my $seq = Math::NumSeq::ErdosSelfridgeClass->new;
 my ($i, $value) = $seq->next;

DESCRIPTION

This is a class number for primes by Erdos and Selfridge, or 0 for composites. The default is "class+"

    0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 2, 0, 0, 0, 1, 0, 2, 0, 0, ...
    starting i=1,

A prime p is classified by factorizing p+1 into primes, then on each of those primes q factorizing q+1, and so on, repeating until reaching entirely 2s and 3s. p=2 or p=3 interchange on factorizing p+1 (2+1=3 and 3+1=2*2).

A prime p where p+1 factorizes to all 2s or 3s is class 1. For example i=11 has 11+1=12=2*2*3 which is all 2s and 3s so class 1. 2 and 3 themselves are class 1 too, since their p+1 factorizing gives 2s and 3s.

Further primes are classified by how many iterations of the p+1 factorizing is necessary to reach 2s and 3s. For example prime p=3847 is iterated as

    3847+1 = 2*13*37

    then 13+1 = 2*7
         37+1 = 2*19

    then 7+1 = 2*2*2
         19+1 = 2*2*5

    then 5+1 = 2*3

So 3847 is class 4 as it took 4 steps to reach all 2s and 3s. Some of the factors become 2s and 3s earlier, but the steps continue until all factors are reduced to 2s and 3s.

Class -

Option on_values => '-' applies the same procedure to prime factors of p-1, giving a "class-" number.

    0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 2, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, ...

It sometimes happens that class+ is the same as class-, but in general the two are unrelated.

Primes Only

Option on_values => 'primes' selects the classes of just the primes,

    1, 1, 1, 1, 1, 2, 1, 2, 1, 2, 1, 3, 2, 2, 1, 1, 2, 2, 2, 1, 4, ...

FUNCTIONS

See "FUNCTIONS" in Math::NumSeq for behaviour common to all sequence classes.

$seq = Math::NumSeq::ErdosSelfridgeClass->new ()
$seq = Math::NumSeq::ErdosSelfridgeClass->new (p_or_m => $str, on_values => 'all')

Create and return a new sequence object.

p_or_m (a string) can be

    "+"    factors of p+1 (the default)
    "-"    factors of p-1

on_values (a string) can be

    "all"      classify all integers
    "primes"   classify just the primes

Random Access

$value = $seq->ith($i)

Return the class number of $value, or 0 if $value is not a prime.

This method is only available for the default on_values=>'all'.

$bool = $seq->pred($value)

Return true if $value occurs as a classification, which means any integer $value >= 0.

SEE ALSO

Math::NumSeq, Math::NumSeq::Primes

HOME PAGE

http://user42.tuxfamily.org/math-numseq/index.html

LICENSE

Copyright 2012, 2013 Kevin Ryde

Math-NumSeq is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.

Math-NumSeq is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with Math-NumSeq. If not, see <http://www.gnu.org/licenses/>.