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+" starting i=1,
0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 2, 0, 0, 0, 1, 0, 2, 0, 0, ...
A prime p is classified by factorizing p+1 into primes, then on each of those factorizing again each q+1, and so on, repeating until reaching entirely 2s and 3s. p=2 or p=3 merely interchange on factorizing p+1 (2+1=3 and 3+1=2*2).
A prime p with factors of p+1 all 2 or 3 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 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 => '+', on_values => 'all')
-
Create and return a new sequence object.
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 in the sequence, which means any integer$value >= 0
.