/- Copyright 2026 The Formal Conjectures Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -/ import FormalConjecturesUtil

Period of $p$-th powers modulo $n$

a: Period of cubes mod $n$. The $n$-th term $a(n)$ is the smallest positive integer $T$ such that $\forall k \in \mathbb{N}$, $(k+T)^3 \equiv k^3 \pmod n$.

The length of the minimal positive period of the sequence $k^p \pmod n$. $a_p(n) = \min { T \in \mathbb{N}^+ \mid \forall k \in \mathbb{N}, (k+T)^p \equiv k^p \pmod n }$.

References:

    A282779

    arxiv/2605.22763 Advancing Mathematics Research with AI-Driven Formal Proof Search by George Tsoukalas et al.

namespace OeisA282779open Nat Set

Period of cubes mod $n$. The $n$-th term $a(n)$ is the smallest positive integer $T$ such that $\forall k \in \mathbb{N}$, $(k+T)^3 \equiv k^3 \pmod n$.

noncomputable def a (n : ) : := if n = 0 then 0 -- Handle the non-sequence index n=0 else -- sInf computes the infimum of the set, which is the minimum since ℕ is well-ordered. sInf { T : | 0 < T k : , (k + T) ^ 3 % n = k ^ 3 % n }

The length of the minimal positive period of the sequence $k^p \pmod n$. $a_p(n) = \min { T \in \mathbb{N}^+ \mid \forall k \in \mathbb{N}, (k+T)^p \equiv k^p \pmod n }$.

noncomputable def periodOfPowerMod (p n : ) : := if n = 0 then 0 else sInf { T : | 0 < T k : , (k + T) ^ p % n = k ^ p % n }

Conjecture: let $a_p(n)$ be the length of the period of the sequence $k^p \bmod n$ where $p$ is a prime, then $a_p(n) = n/p$ if $n \equiv 0 \pmod{p^2}$, else $a_p(n) = n$.

A formal proof has been found with the methods described in arxiv/2605.22763.

@[category research solved, AMS 11, formal_proof using formal_conjectures at "https://github.com/mo271/formal-conjectures/blob/a32396489dcb8f86c3549b93aa358ac6a10a3a1f/FormalConjectures/OEIS/282779.wip.lean#L104"] theorem periodOfPowerMod_eq (p n : ) (hp : Nat.Prime p) (hn : n > 0) : periodOfPowerMod p n = if p ^ 2 n then n / p else n := p:n:hp:Nat.Prime phn:n > 0periodOfPowerMod p n = if p ^ 2 n then n / p else n All goals completed! 🐙@[category test, AMS 11] lemma a_1 : a 1 = 1 := a 1 = 1 exact periodOfPowerMod_eq 3 1 (Nat.Prime 3 All goals completed! 🐙) (1 > 0 All goals completed! 🐙)@[category test, AMS 11] lemma a_2 : a 2 = 2 := a 2 = 2 exact periodOfPowerMod_eq 3 2 (Nat.Prime 3 All goals completed! 🐙) (2 > 0 All goals completed! 🐙)@[category test, AMS 11] lemma a_3 : a 3 = 3 := a 3 = 3 exact periodOfPowerMod_eq 3 3 (Nat.Prime 3 All goals completed! 🐙) (3 > 0 All goals completed! 🐙)@[category test, AMS 11] lemma a_4 : a 4 = 4 := a 4 = 4 exact periodOfPowerMod_eq 3 4 (Nat.Prime 3 All goals completed! 🐙) (4 > 0 All goals completed! 🐙)@[category test, AMS 11] lemma a_5 : a 5 = 5 := a 5 = 5 exact periodOfPowerMod_eq 3 5 (Nat.Prime 3 All goals completed! 🐙) (5 > 0 All goals completed! 🐙)end OeisA282779