Zulip Chat Archive

Stream: new members

Topic: number


BANGJI HU (Oct 30 2024 at 08:53):

Let n be a positive integer. All numbers m which are coprime to n all satisfy m^6 = 1 (mod n) . Find the maximum possible value of n.

BANGJI HU (Oct 30 2024 at 08:54):

import Mathlib.NumberTheory.Basic -- 导入基础数论库


def coprime (a b : ) : Prop := Nat.gcd a b = 1


def satisfiesMod6 (m n : ) : Bool := (m ^ 6) % n == 1


def allCoprimeSatisfyDec (n : ) : Bool :=
  (List.range n).all (fun m => if Nat.gcd m n == 1 then satisfiesMod6 m n else true)


def findMaxN (current maxN : ) :  :=
  if current = 0 then maxN
  else if allCoprimeSatisfyDec current then findMaxN (current - 1) current
  else findMaxN (current - 1) maxN


def maxValidN :  := findMaxN 9 0

#eval maxValidN

BANGJI HU (Oct 30 2024 at 12:15):

why does the output is 2 rather then 504

Trebor Huang (Oct 30 2024 at 15:01):

You started the search at 9 (and you are searching downwards), so it found the largest one below 9, which is 2.

Notification Bot (Oct 30 2024 at 15:12):

This topic was moved here from #mathlib4 > number by Eric Wieser.

BANGJI HU (Oct 30 2024 at 15:22):

Trebor Huang said:

You started the search at 9 (and you are searching downwards), so it found the largest one below 9, which is 2.

I only know how to validate in the range but I don't know how to formalize the proposition and especially to find the maximum, the key to my problem is how to prove that 504 is the maximum with lean

BANGJI HU (Oct 30 2024 at 15:27):

@Trebor Huang


Last updated: May 02 2025 at 03:31 UTC