# NAME

Math::NumSeq::MobiusFunction -- Mobius function sequence

# SYNOPSIS

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

# DESCRIPTION

The sequence of the Mobius function,

``````    1, -1, -1, 0, -1, 1, ...
starting i=1``````

Each value is

``````    1   if i has an even number of distinct prime factors
-1  if i has an odd number of distinct prime factors
0   if i has a repeated prime factor``````

The sequence starts from i=1 and it's reckoned as no prime factors, ie. 0 factors, which is considered even, hence value=1. Then i=2 and i=3 are value=-1 since they have one prime factor (they're primes), and i=4 is value=0 because it's 2*2 which is a repeated prime 2.

# FUNCTIONS

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

`\$seq = Math::NumSeq::MobiusFunction->new ()`

Create and return a new sequence object.

## Random Access

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

Return the Mobius function of `\$i`, being 1, 0 or -1 according to the prime factors of `\$i`.

This calculation requires factorizing `\$i` and in the current code small primes are checked then a hard limit of 2**32 is placed on `\$i`, in the interests of not going into a near-infinite loop.

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

Return true if `\$value` occurs in the sequence, which means simply 1, 0 or -1.

"moebius" in Math::Prime::Util