1Math::NumSeq::DigitSumMUosdeurloC(o3n)tributed Perl DocuMmaetnht:a:tNiuomnSeq::DigitSumModulo(3)
2
3
4
6 Math::NumSeq::DigitSumModulo -- digit sum taken modulo a given modulus
7
9 use Math::NumSeq::DigitSumModulo;
10 my $seq = Math::NumSeq::DigitSumModulo->new (radix => 10,
11 modulus => 9);
12 my ($i, $value) = $seq->next;
13
15 The sum of digits in each i, taken modulo the radix or a given modulus.
16 For example at i=123 with modulus 5 the value is 1+2+3=6, mod 5 = 1.
17
18 Modulus 0, which is the default, means modulo the radix.
19
20 Thue-Morse Sequence
21 For "radix=>2, modulus=>2" this is the Thue-Morse "parity" sequence,
22 being 1 if i has an odd number of 1 bits or 0 if an even number of 1
23 bits. Numbers where it's 1 are sometimes called "odious" numbers and
24 where it's 0 called "evil" numbers.
25
27 See "FUNCTIONS" in Math::NumSeq for behaviour common to all sequence
28 classes.
29
30 "$seq = Math::NumSeq::DigitSumModulo->new (radix => $r, modulus => $d)"
31 Create and return a new sequence object.
32
33 Random Access
34 "$value = $seq->ith($i)"
35 Return the sum of the digits in $i written in "radix", modulo the
36 "modulus".
37
38 "$bool = $seq->pred($value)"
39 Return true if $value might occur as value in the sequence, which
40 means simply $value = 0> and "$value <= modulus" (the given
41 "modulus" or the "radix" if modulus=0).
42
44 Math::NumSeq, Math::NumSeq::DigitSum, Math::NumSeq::MephistoWaltz
45
47 <http://user42.tuxfamily.org/math-numseq/index.html>
48
50 Copyright 2011, 2012, 2013, 2014 Kevin Ryde
51
52 Math-NumSeq is free software; you can redistribute it and/or modify it
53 under the terms of the GNU General Public License as published by the
54 Free Software Foundation; either version 3, or (at your option) any
55 later version.
56
57 Math-NumSeq is distributed in the hope that it will be useful, but
58 WITHOUT ANY WARRANTY; without even the implied warranty of
59 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
60 General Public License for more details.
61
62 You should have received a copy of the GNU General Public License along
63 with Math-NumSeq. If not, see <http://www.gnu.org/licenses/>.
64
65
66
67perl v5.28.1 2014-06-29 Math::NumSeq::DigitSumModulo(3)