Math::NumSeq::ErdosSelfridgeClass -- Erdos-Selfridge classification of primes
use Math::NumSeq::ErdosSelfridgeClass; my $seq = Math::NumSeq::ErdosSelfridgeClass->new; my ($i, $value) = $seq->next;
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.
Option p_or_m => '-' applies the same procedure to prime factors of p-1, giving a "class-" number.
p_or_m => '-'
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.
Option on_values => 'primes' selects the classes of just the primes,
on_values => 'primes'
1, 1, 1, 1, 1, 2, 1, 2, 1, 2, 1, 3, 2, 2, 1, 1, 2, 2, 2, 1, 4, ...
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 => $str)
Create and return a new sequence object.
p_or_m (a string) can be
p_or_m
"+" factors of p+1 (the default) "-" factors of p-1
on_values (a string) can be
on_values
"all" classify all integers "primes" classify just the primes
$value = $seq->ith($i)
Return the class number of $value, or 0 if $value is not a prime.
$value
This method is only available for the default on_values=>'all'. $seq->can('ith') says whether ith() can be used (and gives a coderef).
on_values=>'all'
$seq->can('ith')
ith()
$bool = $seq->pred($value)
Return true if $value occurs as a classification, which means any integer $value >= 0.
$value >= 0
Math::NumSeq, Math::NumSeq::Primes
http://user42.tuxfamily.org/math-numseq/index.html
Copyright 2012, 2013, 2014 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/>.
To install Math::NumSeq, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Math::NumSeq
CPAN shell
perl -MCPAN -e shell install Math::NumSeq
For more information on module installation, please visit the detailed CPAN module installation guide.