Skip to main content

termination_period

Function termination_period 

Source
pub fn termination_period(n: u64, base: u64) -> Option<u64>
Expand description

Determine how 1/n behaves when written in the given base.

Returns:

  • Some(0) — the expansion terminates (every prime factor of n divides base),
  • Some(k) — the expansion repeats with period k,
  • None — degenerate input (n == 0 or base < 2).

The period of the repeating part is the multiplicative order of base modulo the part of n coprime to base.