Math::N...xPrimes(3)

πŸ“¦
version 75 Β· 2 versions
, in fedora 43

πŸ’– NAME πŸ’–

Math::NumSeq::PrimeIndexPrimes β€” it's giving primes that sit at prime number indexes. bestie, that's the whole vibe. (this one lives in the User Contributed Perl Documentation, btw, part of Math-NumSeq πŸŽ€)


✨ SYNOPSIS ✨

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

🌸 DESCRIPTION 🌸

okay so this is the sequence of primes which are at prime indexes, and no cap it's a banger:

3, 5, 11, 17, 31, 41, 59, 67, 83, 109, 127, 157, 179, 191, ...
starting i=1

the primes themselves start like this:

index  prime
  1      2
  2      3     <--+ primes at prime indexes
  3      5     <--+
  4      7        |
  5     11     <--+
  6     13        |
  7     17     <--+
  8     19

the primes marked <-- are the ones whose index is also a prime. iconic behaviour fr fr. πŸ’…

Level

there's an optional level that controls how many repetitions of the prime indexing get applied. the level is based on the order of primeness by Neil Fernandez in the PrimeIndexOrder sequence.

<http://www.borve.org/primeness/FOP.html>

the default is level=2, which asks for primes with an order of primeness >=2. level=1 gives all primes, and level=0 gives all integers.

the next higher level=3 restricts to primes whose index is prime, and then in addition demands that prime is at an index which is prime. the way that stacks?? obsessed.

level => 3
5, 11, 31, 59, 127, 179, 277, 331, 431, 599, ...

successive levels filter further and the remaining values soon become quite large. for example level=11 starts at 9737333 (and is quite slow to generate). 🐌 lowkey painful, ngl.

Level Exact

optional level_type=>'exact' asks for values which have exactly level as their order of primeness.

with the default level 2 this means primes whose index is a prime, but then the index of that index is not a prime, ie. the iterations of prime index stops there,

level_type => 'exact', level => 2
3, 17, 41, 67, 83, 109, 157, 191, 211, 241, 283, 353, ...

here 11 is not in the sequence because its order of primeness is 3, since 11 is at index 5, 5 is at index 3, 3 is at index 2. caught in 4k bestie 🫢

level_type=exact,level=1 means those primes which are at composite indexes. this is all the primes which are not prime index primes, ie. primes not in the default prime-index-primes sequence.

level_type => 'exact', level => 1
2, 7, 13, 19, 23, 29, 37, 43, 47, 53, 61, 71, 73, 79, ...

level_type=exact,level=0 means integers which have order of primeness 0, which is the composites, ie. the non-primes. πŸ’€


πŸ¦‹ FUNCTIONS πŸ¦‹

see "FUNCTIONS" in Math::NumSeq for behaviour common to all sequence classes. (shared lore, iykyk ✨)

  • $seq = Math::NumSeq::PrimeIndexPrimes->new (level => $n) β€” create and return a new sequence object. brand new main character energy πŸ‘‘
  • $i = $seq->value_to_i_estimate($value) β€” return an estimate of the i corresponding to $value. $value can be any size. any size bestie, it does not care 🌈

Formulas

Value to i Estimate

the i for a given value can be estimated by applying the prime-to-i estimate of the plain primes sequence ("Value to i Estimate" in Math::NumSeq::Primes) according to the level parameter.

repeat level many times
  value = Primes value_to_i_estimate(value)

if level_type eq "exact"
  value = value - Primes value_to_i_estimate(value)

i_estimate = value

for example the default level=2 prime index primes applies the Primes estimate twice. a given value is presumed to be a prime, it's index is estimated. then that index also has to be a prime (so the original value is a prime index prime), and the index of that is again estimated by the Primes module. nesting doll behaviour, we love to see it πŸͺ†

for level_type=>'exact' the final index must be a composite, as opposed to "minimum" where it can be either prime or composite. that restriction means an extra final Composite value to i, derived from the Primes by simply

Composite value_to_i_estimate(x)
  = value - Primes value_to_i_estimate(x)

🌈 SEE ALSO 🌈

  • Math::NumSeq
  • Math::NumSeq::Primes
  • Math::NumSeq::PrimeIndexOrder

🏠 HOME PAGE 🏠

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

πŸ“œ LICENSE πŸ“œ

Copyright 2011, 2012, 2013, 2014, 2016, 2019, 2020 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. (yes it's in all caps in the original, they're being very serious about it πŸ™ˆ)

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


and that's the whole page bestie, mwah πŸ’‹ this is perl v5.42.0, dated 2025-07-25, from the Math::N...xPrimes(3) page (yes the title is literally truncated like that, the terminal said what it said πŸ’€). go forth and sequence βœ¨πŸ¦‹πŸ’–

πŸ“¦ where this page comes from