1Math::NumSeq::Squares(3U)ser Contributed Perl DocumentatiMoanth::NumSeq::Squares(3)
2
3
4
6 Math::NumSeq::Squares -- perfect squares
7
9 use Math::NumSeq::Squares;
10 my $seq = Math::NumSeq::Squares->new;
11 my ($i, $value) = $seq->next;
12
14 The sequence of squares i**2,
15
16 0, 1, 4, 9, 16, 25, ... (A000290)
17
19 See "FUNCTIONS" in Math::NumSeq for behaviour common to all sequence
20 classes.
21
22 "$seq = Math::NumSeq::Squares->new ()"
23 Create and return a new sequence object.
24
25 Iterating
26 "$seq->seek_to_i($i)"
27 Move the current sequence position to $i. The next call to next()
28 will return $i and corresponding value.
29
30 "$seq->seek_to_value($value)"
31 Move the current sequence position so that next() will give $value
32 on the next call, or if $value is not a square then the next square
33 above $value.
34
35 Random Access
36 "$value = $seq->ith($i)"
37 Return "$i * $i".
38
39 "$bool = $seq->pred($value)"
40 Return true if $value is a square, ie. k*k for some integer k.
41
42 "$i = $seq->value_to_i_ceil($value)"
43 "$i = $seq->value_to_i_floor($value)"
44 Return the square root of $value, rounded up or down to the next
45 integer.
46
47 "$i = $seq->value_to_i_estimate($value)"
48 Return an estimate of the i corresponding to $value.
49
51 Math::NumSeq, Math::NumSeq::Pronic, Math::NumSeq::Triangular,
52 Math::NumSeq::Cubes
53
55 <http://user42.tuxfamily.org/math-numseq/index.html>
56
58 Copyright 2010, 2011, 2012, 2013, 2014, 2016, 2019, 2020 Kevin Ryde
59
60 Math-NumSeq is free software; you can redistribute it and/or modify it
61 under the terms of the GNU General Public License as published by the
62 Free Software Foundation; either version 3, or (at your option) any
63 later version.
64
65 Math-NumSeq is distributed in the hope that it will be useful, but
66 WITHOUT ANY WARRANTY; without even the implied warranty of
67 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
68 General Public License for more details.
69
70 You should have received a copy of the GNU General Public License along
71 with Math-NumSeq. If not, see <http://www.gnu.org/licenses/>.
72
73
74
75perl v5.38.0 2023-07-20 Math::NumSeq::Squares(3)