Math::N...rnerRado(3)

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

πŸ’– Math::N...rnerRado(3) πŸ’–

okay bestie, gather round, because this is the Math::N...rnerRado(3) page β€” straight out of the User Contributed Perl Documentation, and it's giving mathematical baddie energy. no cap. πŸ¦‹


✨ NAME ✨

Math::NumSeq::KlarnerRado β€” Klarner-Rado sequences πŸ‘‘


🌸 SYNOPSIS 🌸

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

literally three lines and you're in. slay. πŸ’…


πŸŽ€ DESCRIPTION πŸŽ€

so the way this works is iconic: you start with 1, and then for any k that's already in the sequence, these three cuties are also in the sequence:

  • 2*k
  • 3*k+2
  • 6*k+3

and that's it. that's the whole vibe. so the sequence goes 1,2,4,5,8,9,etc. ✨


🫢 FUNCTIONS 🫢

if you wanna know about the behaviour that all the sequence classes share, go look at "FUNCTIONS" in Math::NumSeq β€” that's the group chat everyone's in. πŸ’¬

  • $seq = Math::NumSeq::KlarnerRado->new ()
  • $seq = Math::NumSeq::KlarnerRado->new (start => $n)

makes a brand new sequence object and hands it to you. 🎁

the optional start param lets you kick things off from a value that isn't 1. heads up though β€” that changes the sequence, and ngl, generally bigger values thin out the sequence. so it's a whole different beast. 😭

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

returns true if $value shows up in the sequence. that's it, that's the function. βœ…


πŸ”₯ FORMULAS πŸ”₯

🧚 Predicate

okay this part is the main character moment. if you take value mod 6, you can tell whether it's a descendant of one of the 2*k, 3*k+2, or 6*k+3 forms β€” and that gives you one or two reduced values to go check for being in the sequence. it's giving recursion. πŸ’€

here's the breakdown, one bullet per case because we're organised besties:

  • value mod 6 == 0 β†’ descendant of 2k β†’ reduce to value/2
  • value mod 6 == 1 β†’ descendant of none (nope, not a thing, sorry babe πŸ™ˆ)
  • value mod 6 == 2 β†’ descendant of 2k or 3k+2 β†’ reduce to value/2 and (value-2)/3
  • value mod 6 == 3 β†’ descendant of 6k+3 β†’ reduce to (value-3)/6
  • value mod 6 == 4 β†’ descendant of 2k β†’ reduce to value/2
  • value mod 6 == 5 β†’ descendant of 3k+2 β†’ reduce to (value-2)/3

the reduction dividing out 2, 3 or 6 makes the test logarithmic ✨ β€” except when 2mod6 gives you two reduced values to check, because then you've got double the homework. 😭


πŸ‘€ SEE ALSO πŸ‘€

  • Math::NumSeq

🌈 HOME PAGE 🌈

<http://user42.tuxfamily.org/math-numseq/index.html> β€” go visit, it's cute πŸ πŸ’–


πŸ“œ 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.

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

no cap, read the license fr fr β€” free software is the moment, but the warranty situation is literally "we don't got one" πŸ’€

and that's the whole page, bestie!! πŸŽ€ this was perl v5.42.0, dated 2025-07-25, and it's the Math::N...rnerRado(3) manual β€” thanks for reading the whole thing, you're an icon, an absolute legend, periodt. πŸ’…βœ¨πŸ¦‹πŸ’–

πŸ“¦ where this page comes from