Math::N...erSteps(3)
π NAME π
Math::NumSeq::JugglerSteps β bestie, this is the number of steps in the juggler sqrt sequence. Yes that's the whole job. She counts. She's an icon. π
β¨ SYNOPSIS β¨
use Math::NumSeq::JugglerSteps;
my $seq = Math::NumSeq::JugglerSteps->new;
my ($i, $value) = $seq->next;
okay so literally three lines and you're in. slay. π
π¦ DESCRIPTION π¦
This is the number of steps it takes to reach 1 by the Juggler sqrt sequence, and the rule is giving β¨two moodsβ¨:
n -> / floor(n^(1/2)) if n even
\ floor(n^(3/2)) if n odd
So: if n is even you take sqrt, and if n is odd you take sqrt(n^3), and either way you round downwards. no exceptions. periodt.
For example, i=17 goes 17 -> sqrt(17^3)=70 -> sqrt(70)=8 -> sqrt(8)=2 -> sqrt(2)=1, for a count of 4 steps. the way that just works out?? obsessed. π
0, 1, 6, 2, 5, 2, 4, 2, 7, 7, 4, 7, 4, 7, 6, 3, 4, 3, 9, 3, ...
starting i=1
π«Ά heads up bestie: the intermediate values in the calculation can become quite large and Math::BigInt is used if necessary. There's some secret experimental caching in a temporary file, for a small speedup. it's giving mysterious. don't ask. π€«
π FUNCTIONS π
See "FUNCTIONS" in Math::NumSeq for behaviour common to all sequence classes. (that's the family, they all share these vibes.)
$seq = Math::NumSeq::JugglerSteps->new ()$seq = Math::NumSeq::JugglerSteps->new (step_type => 'both', juggler_type => '1/2-3/2')
Create and return a new sequence object. ur main character moment. π
The optional step_type parameter (a string) selects between:
"up"β upward stepssqrt(n^3)"down"β downward stepssqrt(n)"both"β both up and down, which is the default
The optional juggler_type parameter (a string) selects among variations on the powering:
n even n odd
"1/2-3/2" sqrt(n) and sqrt(n^3)
"2/3-3/2" cbrt(n^2) and sqrt(n^3)
"3/4-4/3" n^(3/4) and n^(4/3)
πΈ Random Access πΈ
$value = $seq->ith($i)β Return the number of steps to take$idown to 1. it's giving direct access, no queueing. β$bool = $seq->pred($value)β Return true if$valueoccurs as a step count. This is simply"$value >= 0". that's it. that's the whole check. lowkey elegant. π
π SEE ALSO π
Math::NumSeqMath::NumSeq::CollatzStepsMath::NumSeq::ReverseAddSteps
(the whole squad, go say hi π«Ά)
π§ HOME PAGE π§
<http://user42.tuxfamily.org/math-numseq/index.html>
π LICENSE π
Copyright 2010, 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. (fr fr, no promises, read the fine print π)
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 π this lil number-crunching legend ships as part of perl v5.42.0, dated 2025-07-25. go forth and juggle some steps β¨π
π¦ 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