Math::N...erSteps(3)

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

πŸ’– 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 steps sqrt(n^3)
  • "down" β€” downward steps sqrt(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 $i down to 1. it's giving direct access, no queueing. ⭐
  • $bool = $seq->pred($value) β€” Return true if $value occurs as a step count. This is simply "$value >= 0". that's it. that's the whole check. lowkey elegant. πŸ’œ

🌈 SEE ALSO 🌈

  • Math::NumSeq
  • Math::NumSeq::CollatzSteps
  • Math::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