1Math::NumSeq::TriangulaUrs(e3r)Contributed Perl DocumentMaattiho:n:NumSeq::Triangular(3)
2
3
4

NAME

6       Math::NumSeq::Triangular -- triangular numbers
7

SYNOPSIS

9        use Math::NumSeq::Triangular;
10        my $seq = Math::NumSeq::Triangular->new;
11        my ($i, $value) = $seq->next;
12

DESCRIPTION

14       The triangular numbers i*(i+1)/2,
15
16           0, 1, 3, 6, 10, 15, 21, 28, ...
17           starting i=0
18
19       The numbers are how many points are in an equilateral triangle of side
20       i,
21
22              *      i=1  1
23
24              *      i=2  3
25             * *
26
27              *
28             * *     i=3  6
29            * * *
30
31              *
32             * *     i=4  10
33            * * *
34           * * * *
35
36       From a given i, the next value is formed by adding i+1, being a new row
37       of that length on the bottom of the triangle.
38

FUNCTIONS

40       See "FUNCTIONS" in Math::NumSeq for behaviour common to all sequence
41       classes.
42
43       "$seq = Math::NumSeq::Triangular->new ()"
44           Create and return a new sequence object.
45
46   Random Access
47       "$value = $seq->ith($i)"
48           Return "$i*($i+1)/2".
49
50       "$bool = $seq->pred($value)"
51           Return true if $value is a triangular number, ie. i*(i+1)/2 for
52           some integer i.
53
54       "$i = $seq->value_to_i_ceil($value)"
55       "$i = $seq->value_to_i_floor($value)"
56           Return the index i of $value, or if $value is not a triangular
57           number then the next higher for "ceil" or lower for "floor".
58
59       "$i = $seq->value_to_i_estimate($value)"
60           Return an estimate of the i corresponding to $value.  This is
61           value=i*(i+1)/2 is inverted to
62
63               $i = int ((sqrt(8*$value + 1) - 1)/2)
64

SEE ALSO

66       Math::NumSeq, Math::NumSeq::Pronic, Math::NumSeq::Squares
67

HOME PAGE

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

LICENSE

72       Copyright 2010, 2011, 2012, 2013, 2014, 2016, 2019 Kevin Ryde
73
74       Math-NumSeq is free software; you can redistribute it and/or modify it
75       under the terms of the GNU General Public License as published by the
76       Free Software Foundation; either version 3, or (at your option) any
77       later version.
78
79       Math-NumSeq is distributed in the hope that it will be useful, but
80       WITHOUT ANY WARRANTY; without even the implied warranty of
81       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
82       General Public License for more details.
83
84       You should have received a copy of the GNU General Public License along
85       with Math-NumSeq.  If not, see <http://www.gnu.org/licenses/>.
86
87
88
89perl v5.32.1                      2021-01-27       Math::NumSeq::Triangular(3)
Impressum