Ramanujan's Lost Notebook Part II, Ch. 11: ch11Inverse
DefinitionRamanujanLostNotebook_PartII_ch11_ch11Inversenumber-theoryramanujan-lost-notebook
Least nonnegative inverse of d modulo c, selected by a finite sum. On the representative locus c>=2 and gcd(c,d)=1 there is precisely one such inverse.
Definition code
import Mathlib noncomputable section namespace RamanujanLostNotebook.PartII /-- Least nonnegative inverse of d modulo c, selected by a finite sum. On the representative locus c>=2 and gcd(c,d)=1 there is precisely one such inverse. -/ def ch11Inverse (c d : ℕ) : ℕ := ∑ a ∈ Finset.range c, if (a * d) % c = 1 then a else 0 end RamanujanLostNotebook.PartII end
Source
G. E. Andrews and B. C. Berndt, Ramanujan's Lost Notebook, Part II, Springer 2009, Chapter 11.