Function of #cas
eulerPhi
Euler’s totient , the number of residues modulo coprime to , with a theorem about Mathlib’s Nat.totient.
#cas (eulerPhi n)Nat.totient n = t.eulerPhi computes Euler’s totient, the number of residues modulo that are coprime to . The theorem is about Mathlib’s Nat.totient itself, not a function of our own, so a proof about the totient can use the printed value directly.
Examples (8)#
Basic Examples (1)
Forty of the residues modulo 100 are coprime to 100, and the theorem says so:
#cas (eulerPhi 100)
eulerPhi
40- Domain
ℕ- Input (natural numbers)
100
Checked by Lean’s kernel: eulerPhi
Nat.totient 100 = 40
The certificate: 1 checked step
eulerPhi
Nat.totient 100 = 40
Scope (3)
A closed integer expression is evaluated first. Modulo the coprime residues are the odd ones, half of them:
#cas (eulerPhi (2 ^ 10))
eulerPhi
512- Domain
ℕ- Input (natural numbers)
1024
Checked by Lean’s kernel: eulerPhi
Nat.totient 1024 = 512
The certificate: 1 checked step
eulerPhi
Nat.totient 1024 = 512
Mathlib sets :
#cas (eulerPhi 0)
eulerPhi
0- Domain
ℕ- Input (natural numbers)
0
Checked by Lean’s kernel: eulerPhi
Nat.totient 0 = 0
The certificate: 1 checked step
eulerPhi
Nat.totient 0 = 0
An expression may pass through large numbers, here , and the argument is its value, 100:
#cas (eulerPhi (10 ^ 9000 / 10 ^ 8998))
eulerPhi
40- Domain
ℕ- Input (natural numbers)
100
Checked by Lean’s kernel: eulerPhi
Nat.totient 100 = 40
The certificate: 1 checked step
eulerPhi
Nat.totient 100 = 40
Applications (1)
Properties and Relations (1)
The product formula runs over the distinct prime factors of . For it gives :
#cas (eulerPhi 360)
eulerPhi
96- Domain
ℕ- Input (natural numbers)
360
Checked by Lean’s kernel: eulerPhi
Nat.totient 360 = 96
The certificate: 1 checked step
eulerPhi
Nat.totient 360 = 96
Possible Issues (2)
The expression 10 ^ 10000 / 10 ^ 9998 has the value 100, but has 10001 digits:
#cas (eulerPhi (10 ^ 10000 / 10 ^ 9998))
Error
eulerPhi: `10 ^ 10000` has more than 10000 digits, the most that a call computes
A call inside another call is not evaluated, since gamma is evaluated only as the whole input of #cas:
#cas (eulerPhi (gamma 3))
Error
eulerPhi takes integer arguments; `gamma x` is evaluated as the whole input of `#cas (gamma x)`
See Also
divisorSigma · moebiusMu · factorInteger · divisors · powerMod
