Math::N...pySteps(3)
β¨ NAME β¨
Math::NumSeq::HappySteps β the number of sum-of-squares-of-digits iterations you gotta do before something repeats π«
(also, hi, this is the Math::N...pySteps(3) page, bestie, welcome to the group chat π«Ά)
πΈ SYNOPSIS πΈ
use Math::NumSeq::HappySteps;
my $seq = Math::NumSeq::HappySteps->new (radix => 10);
my ($i, $value) = $seq->next;
π DESCRIPTION π
okay so basically: this is the number of iterations of the "HappyNumbers"-style "sum of squares of digits" thing that you need to run before you hit a repeat of a value you've already seen. and once you hit that repeat, boom, you know whether the number is a happy number or not. that's the whole vibe check. π
1, 9, 13, 8, 12, 17, 6, 13, 12, 2,
starting i=1
like, for example, i=10 is value 2 because 10->1->1 is 2 iterations to get to a repeat (a repeat of 1). and at i=1 itself the value is 1 since 1 iteration reaches 1 again, which is literally itself the repeat. that count 1 at i=1 is the minimum. no cap. π
π’ Radix π’
there's an optional radix parameter that picks a base other than decimal. in binary, radix=>2, the digits are all either 0 or 1, so "sum of squares of digits" is literally the same thing as a plain "sum of digits". slay. π
in some bases there's longer cycles than others which a non-happy number might fall into. for example, base 20 has a cycle:
10 -> 100 -> 25 -> 26 -> ... -> 61 -> 10
total 26 elements
when a non-happy falls into such a cycle, its HappySteps count here is at least 26 (or whatever amount) to reach a repeat. so like, the cycle is long and you're stuck in it for a while, bestie. π
π¦ FUNCTIONS π¦
see "FUNCTIONS" in Math::NumSeq for behaviour common to all sequence classes.
$seq = Math::NumSeq::HappySteps->new ()$seq = Math::NumSeq::HappySteps->new (radix => $r)
β create and return a new sequence object. new seq, who dis β¨
π² Random Access π²
$value = $seq->ith($i)β return the number of iterations starting from$irequired to reach a repeat. just hand it an index and it hands you the count, iconic behaviour π«Ά
π SEE ALSO π
Math::NumSeq, Math::NumSeq::HappyNumbers, Math::NumSeq::DigitSum
π 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.
You should have received a copy of the GNU General Public License along with Math-NumSeq. If not, see <http://www.gnu.org/licenses/>.
fr fr read the license, it's giving legally binding but make it cute π
and that's the whole page bestie!! this lil masterpiece dropped as perl v5.42.0 on 2025-07-25, and it's the Math::N...pySteps(3) page β ty for coming to my TED talk, mwah π
πβ¨
π¦ where this page comes from
- fedora 43: perl-Math-NumSeq 75-11.fc43 Β· GPL-3.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms