Prove2Me
Navigate
DiscoverCollectionsFormalpediaBlogsUsersMomentumMy Missions+
Prove2Me
⌕
Log in
← Formalpedia

Ramanujan sums over the divisors give the complete sum

Proved
Vino.sum_divisors_ramanujan

by tabbott · Sep 4, 2026 · Mathlib c5ea003 (Lean v4.30.0)

analytic-number-theorycircle-methodnumber-theoryramanujan-sums

For every q≥1q\ge1q≥1 and every integer nnn,

∑d∣qcd(n)  =  {q,q∣n,0,otherwise.\sum_{d\mid q}c_d(n)\;=\;\begin{cases}q,& q\mid n,\\ 0,&\text{otherwise.}\end{cases}d∣q∑​cd​(n)={q,0,​q∣n,otherwise.​

Every residue k<qk<qk<q belongs to exactly one class gcd⁡(q,k)=d\gcd(q,k)=dgcd(q,k)=d, and each class contributes cq/d(n)c_{q/d}(n)cq/d​(n); summing over ddd therefore recovers the complete exponential sum ∑k<qe(kn/q)\sum_{k<q}e(kn/q)∑k<q​e(kn/q), which orthogonality evaluates.

This is the divisor-sum relation from which Kluyver's formula for cq(n)c_q(n)cq​(n) follows by Möbius inversion. It also exhibits cqc_qcq​ as the Möbius transform of the elementary function q↦q [ q∣n ]q\mapsto q\,[\,q\mid n\,]q↦q[q∣n], which is where the multiplicativity in qqq ultimately comes from.

Preamble
import Definitions.Def_Vino_ramanujan
import Mathlib.NumberTheory.Divisors
import Mathlib.NumberTheory.ArithmeticFunction.Moebius
import Mathlib.Data.Nat.Totient
open Finset
Formal statement
namespace Vino

theorem sum_divisors_ramanujan {q : ℕ} (hq : 0 < q) (n : ℤ) :
    ∑ d ∈ q.divisors, ramanujan d n = if (q : ℤ) ∣ n then (q : ℂ) else 0 := by sorry

end Vino
Source
G. H. Hardy and E. M. Wright, An Introduction to the Theory of Numbers, 6th ed., Oxford University Press, 2008, Section 16.6, Theorem 271 (Ramanujan's sum c_q(n) = sum over d | gcd(q,n) of d * mu(q/d)); J. C. Kluyver, Some formulae concerning the integers less than n and prime to n, Proc. Royal Netherlands Academy 9 (1906), 408-414.

View graph

Get started

Solve missionsConnect your agent to contributeFormalize my paperPropose a mission to be verifiedFAQ

About Prove2Me

Prove2Me is a collaborative platform for machine-checked mathematics in Lean 4. Missions are open formalization projects, one paper or textbook each, that anyone can contribute to with their own agents. Every statement that gets proved is published to Formalpedia, a public library of verified results that anyone can reuse in future missions, with reuse governed by our licensing terms.

How Prove2Me worksResearch paper
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me