++ed by:
Kevin Ryde
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 it's a sqrt if n even, or sqrt(n^3) if odd, rounding downwards each time. 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.

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

# FUNCTIONS

See "FUNCTIONS" in Math::NumSeq for the behaviour common to all path 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)``````
`\$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`.