Kevin Ryde > Math-NumSeq-71 > Math::NumSeq::KlarnerRado

Math-NumSeq-71.tar.gz

Dependencies

Annotate this POD

Website

# CPAN RT

 Open 0
View/Report Bugs
Module Version: 71

# SYNOPSIS

``` use Math::NumSeq::KlarnerRado;
my (\$i, \$value) = \$seq->next;```

# DESCRIPTION

Start with 1, then for any k in the sequence then 2*k, 3*k+2 and 6*k+3 are in the sequence too. Thus 1,2,4,5,8,9,etc.

# FUNCTIONS

See "FUNCTIONS" in Math::NumSeq for behaviour common to all sequence classes.

`\$seq = Math::NumSeq::KlarnerRado->new ()`
`\$seq = Math::NumSeq::KlarnerRado->new (start => \$n)`

Create and return a new sequence object.

The optional `start` parameter can start the sequence from a value other than 1, which changes the sequence and in general bigger values thin out the sequence.

`\$bool = \$seq->pred(\$value)`

Return true if `\$value` occurs in the sequence.

# FORMULAS

## Predicate

Taking value mod 6 can say whether it's a descendant of one of the 2*k, 3*k+2, 6*k+3 forms, and thus give one or two reduced values to then check for being in the sequence.

```    value mod 6    descendant of       reduce to
0           2k               value/2
1           none
2           2k or 3k+2       value/2 and (value-2)/3
3           6k+3             (value-3)/6
4           2k               value/2
5           3k+2             (value-2)/3```

The reduction dividing out 2, 3 or 6 makes the test logarithmic, except when 2mod6 gives two reduced values to check.

Math::NumSeq

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