| 1 | # Copyright 2012, 2013, 2014, 2016, 2017, 2019, 2020 Kevin Ryde | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | # This file is part of Math-NumSeq. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | # Math-NumSeq is free software; you can redistribute it and/or modify | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | # it under the terms of the GNU General Public License as published by the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | # Free Software Foundation; either version 3, or (at your option) any later | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | # version. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | # Math-NumSeq is distributed in the hope that it will be useful, but | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | # for more details. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | # You should have received a copy of the GNU General Public License along | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | # with Math-NumSeq. If not, see <http://www.gnu.org/licenses/>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | package Math::NumSeq::ErdosSelfridgeClass; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 2 | ▶ | use 5.004; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 2 | ▶ | use Math::NumSeq::Primes; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 2 | ▶ | use vars '$VERSION', '@ISA'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 2 | $VERSION = 75; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 2 | ▶ | use Math::NumSeq; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 2 | @ISA = ('Math::NumSeq'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 2 | ▶ | use Math::NumSeq::PrimeFactorCount;; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 2 | *_prime_factors = \&Math::NumSeq::PrimeFactorCount::_prime_factors; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | # use constant name => Math::NumSeq::__('Erdos-Selfridge Class'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 2 | ▶ | use constant description => Math::NumSeq::__('Erdos-Selfridge class of a prime.'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 2 | ▶ | use constant default_i_start => 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 2 | ▶ | use constant characteristic_integer => 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 2 | ▶ | use constant characteristic_increasing => 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 2 | ▶ | use constant characteristic_non_decreasing => 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 2 | ▶ | use constant characteristic_smaller => 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 2 | ▶ | use constant values_min => 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 2 | ▶ | use constant parameter_info_array => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | { name => 'p_or_m', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | display => Math::NumSeq::__('+/-'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | type => 'enum', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | default => '+', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | choices => ['+','-'], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | choices_display => [Math::NumSeq::__('+'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | Math::NumSeq::__('-')], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | description => Math::NumSeq::__('Class + or -, factorizing p+1 or p-1 respectively in the classification.'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | { name => 'on_values', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | share_key => 'on_values_primes', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | display => Math::NumSeq::__('On Values'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | type => 'enum', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | default => 'all', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | choices => ['all','primes'], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | choices_display => [Math::NumSeq::__('All'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | Math::NumSeq::__('Primes')], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | description => Math::NumSeq::__('Values to classify, either all integers or just the primes.'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 2 | ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | # cf A098661 cumulative class+ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | # A005109 1-, Pierpont | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | # A005110 2- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | # A005111 3- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | # A005112 4- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | # A081424 5- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | # A081425 6- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | # A081640 12- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | # A129248 14- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | # A129249 15- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | # A129250 16- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | # A005105 1+ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | # A005106 2+ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | # A005107 3+ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | # A005108 4+ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | # A081633 5+ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | # ... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | # A081639 11+ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | # A084071 12+ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | # A090468 13+ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | # A129474 14+ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | # A129475 15+ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | # A178382 in both k+ and k- for some k | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | # A005113 least prime in class n+ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | # A056637 least prime of class n- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | # A129470 where largest factor of p+1 isn't largest class | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | # A129469 first prime of class n+ in A129470 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | # A129471 3+ with largest factor of p+1 not in 2+ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | # A129472 4+ with largest factor of p+1 not in 3+ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 2 | my %oeis_anum = ('+' => { 'primes' => 'A126433', # class+ of primes | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 'all' => 'A078442', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | '-' => { 'primes' => 'A126805', # class- of primes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | # OEIS-Catalogue: A126433 on_values=primes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | # OEIS-Catalogue: A126805 on_values=primes p_or_m=- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 3 | ▶ | sub oeis_anum { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
oeis_anum: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 3 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 3 | return $oeis_anum{$self->{'p_or_m'}}->{$self->{'on_values'}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 11 | ▶ | sub rewind { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
rewind: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 11 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 11 | $self->{'i'} = $self->i_start; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 11 | ▶ | if ($self->{'on_values'} eq 'primes') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 3 | $self->{'seq'} = Math::NumSeq::Primes->new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 126 | ▶ | sub next { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
next: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 126 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 126 | my $i = $self->{'i'}++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 126 | my $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 126 | ▶ | if (my $seq = $self->{'seq'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 42 | (undef, $value) = $self->{'seq'}->next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 84 | $value = $i; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 126 | return ($i, _classify($self,$value)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 134 | ▶ | sub ith { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ith: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 134 | my ($self, $i) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 134 | ▶ | if ($self->{'on_values'} eq 'primes') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | return undef; # no i'th prime yet | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 134 | return _classify($self,$i); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 500 | ▶ | sub can { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
can: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 500 | my ($class_or_self, $method) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 500 | ▶ | if (($method eq 'ith' || $method eq 'seek_to_i') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition88%8/9
$method eq "ith" || $method eq "seek_to_i" and ref $class_or_self and $class_or_self->{"on_values"} eq "primes"
$method eq "ith" || $method eq "seek_to_i" and ref $class_or_self
$method eq "ith" or $method eq "seek_to_i"
MC/DC75%3/4
$method eq "ith" || $method eq "seek_to_i" and ref $class_or_self and $class_or_self->{"on_values"} eq "primes"
$method eq "ith"
$method eq "seek_to_i"
ref $class_or_self
$class_or_self->{"on_values"} eq "primes"
Truth table71%5/7
A or B and C and D
A= $method eq "ith"B= $method eq "seek_to_i"C= ref $class_or_selfD= $class_or_self->{"on_values"} eq "primes"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | && ref $class_or_self | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | && $class_or_self->{'on_values'} eq 'primes') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 4 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 496 | return $class_or_self->SUPER::can($method); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 260 | ▶ | sub _classify { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_classify: called CC=6 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 260 | my ($self, $i) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 260 | ▶ | Math::NumSeq::Primes->pred($i) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | or return 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 124 | ▶ | my $offset = ($self->{'p_or_m'} eq '+' ? 1 : -1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 124 | my $ret = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 124 | my @this = ($i); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 124 | ▶ | while (@this) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 171 | $ret++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 171 | my %next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 171 | foreach my $prime (@this) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 175 | my ($good, @primes) = _prime_factors($prime + $offset); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 175 | ▶ | return undef unless $good; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 175 | @next{@primes} = (); # hash slice, for uniq | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 171 | delete @next{2,3}; # hash slice, not 2 or 3 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 171 | @this = keys %next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 124 | return $ret; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 63 | ▶ | sub pred { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pred: called CC=2 SCAR=8.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 63 | my ($self, $value) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 63 | ▶ | return ($value >= 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$value >= 0 && $value == int $value
MC/DC0%0/2
$value >= 0 && $value == int $value
$value >= 0
$value == int $value
Truth table33%1/3
A && B
A= $value >= 0B= $value == int $value
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | && $value == int($value)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||