and 1 contributors

# NAME

Math::NumSeq::JugglerSteps -- steps in the juggler sqrt sequence

# SYNOPSIS

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

# DESCRIPTION

This is the number of steps it takes to reach 1 by the Juggler sqrt sequence,

``````    n ->  /  floor(n^(1/2))      if n even
\  floor(n^(3/2))      if n odd``````

So sqrt if n even, or sqrt(n^3) if n odd, each rounded downwards. For example i=17 goes 17 -> sqrt(17^3)=70 -> sqrt(70)=8 -> sqrt(8)=2 -> sqrt(2)=1, for a count of 4 steps.

``````    0, 1, 6, 2, 5, 2, 4, 2, 7, 7, 4, 7, 4, 7, 6, 3, 4, 3, 9, 3, ...
starting i=1``````

The intermediate values in the calculation can become quite large and `Math::BigInt` is used if necessary. There's some secret experimental caching in a temporary file, for a small speedup.

# FUNCTIONS

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

`\$seq = Math::NumSeq::JugglerSteps->new ()`
`\$seq = Math::NumSeq::JugglerSteps->new (step_type => 'both', juggler_type => '1/2-3/2')`

Create and return a new sequence object.

The optional `step_type` parameter (a string) selects between

``````    "up"      upward steps sqrt(n^3)
"down"    downward steps sqrt(n)
"both"    both up and down, which is the default``````

The optional `juggler_type` parameter (a string) selects among variations on the powering

``````                  n even        n odd
"1/2-3/2"    sqrt(n)   and sqrt(n^3)
"2/3-3/2"    cbrt(n^2) and sqrt(n^3)
"3/4-4/3"    n^(3/4)   and n^(4/3)``````

## Random Access

`\$value = \$seq->ith(\$i)`

Return the number of steps to take `\$i` down to 1.

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

Return true if `\$value` occurs as a step count. This is simply `\$value >= 0`.