Math::N...:Squares(3)

๐Ÿ“ฆ
version 75 ยท 2 versions
, in fedora 43

๐Ÿ‘‘ Math::N...:Squares(3) โ€” user contributed perl documentation, bestie edition ๐Ÿ’…

okay so this page lives in the User Contributed Perl Documentation corner of the perl manual universe, and it's all about Math::NumSeq::Squares โ€” the perfect squares sequence. yes, THE squares. the ones you learned in like third grade and never emotionally recovered from. let's go ๐ŸŽ€


โœจ NAME โœจ

Math::NumSeq::Squares โ€” perfect squares, no cap ๐ŸŸช


๐ŸŒˆ SYNOPSIS ๐ŸŒˆ

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

that's it. that's the whole vibe. make the object, pull numbers out of it, slay. ๐Ÿ’–


๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

it's the sequence of squares, aka i**2, and it goes a lil something like:

0, 1, 4, 9, 16, 25, ...     (A000290)

the way that A000290 is just right there being its iconic OEIS self ๐Ÿ˜ญ๐Ÿ‘‘


๐Ÿ’œ FUNCTIONS ๐Ÿ’œ

heads up bestie โ€” for the behaviour that's common to all the sequence classes, go read "FUNCTIONS" in Math::NumSeq. this page is just the squares-specific stuff. ๐Ÿซถ

  • $seq = Math::NumSeq::Squares->new () โ€” creates and hands you back a shiny new sequence object. fresh out the box, zero notes. โœจ

๐Ÿงš Iterating

  • $seq->seek_to_i($i) โ€” scoots the current sequence position over to $i. then the very next call to next() is gonna hand you $i and its matching value. like fast-forwarding to your fave part of the song. ๐ŸŽง
  • $seq->seek_to_value($value) โ€” moves the current position so that next() gives you $value on the next call. BUT โ€” and this is the plot twist โ€” if $value isn't actually a square, then you get the next square above $value instead. the audacity. the drama. ๐Ÿ’€

๐Ÿ”ฅ Random Access

  • $value = $seq->ith($i) โ€” returns "$i * $i". simple. elegant. iconic.
  • $bool = $seq->pred($value) โ€” returns true if $value is a square, i.e. k*k for some integer k. vibe check: passed or not passed, no in-between. ๐Ÿ’…
  • $i = $seq->value_to_i_ceil($value) โ€” returns the square root of $value, rounded up to the next integer. โฌ†๏ธ
  • $i = $seq->value_to_i_floor($value) โ€” returns the square root of $value, rounded down to the next integer. โฌ‡๏ธ
  • $i = $seq->value_to_i_estimate($value) โ€” returns an estimate of the i that corresponds to $value. an educated guess, a lil peek into the future, we love her. ๐Ÿ”ฎ

๐ŸŒธ SEE ALSO ๐ŸŒธ

  • Math::NumSeq
  • Math::NumSeq::Pronic
  • Math::NumSeq::Triangular
  • Math::NumSeq::Cubes

the whole squad fr fr ๐Ÿซถ๐Ÿฆ‹


๐ŸŒˆ HOME PAGE ๐ŸŒˆ

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

go visit, she's gorgeous, tell her i said hi ๐Ÿ’–


๐ŸŽ€ 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.

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 warranty bestie, the lawyers made me say it ๐Ÿ˜ญ read the GPL, it's giving legally binding main character energy ๐Ÿ‘‘

and that's the whole page!! ๐Ÿ’œ this was perl v5.42.0, dated 2025-07-25, straight from the Math::N...:Squares(3) page โ€” mwah, bye, go square something ๐Ÿงšโœจ

๐Ÿ“ฆ where this page comes from