Zulip Chat Archive
Stream: Is there code for X?
Topic: Is there a function already defined for this?
Ching-Tsun Chou (Sep 16 2025 at 00:52):
Given f : ℕ → ℕ (where we may assume ∀ n, f n > 0) and k : ℕ, I wish to find the largest n : ℕ such that:
(∑ i < n, f i) ≤ k
Is such a function already defined in mathlib?
(Yes, I do know about Nat.findGreatest. I'm just wondering whether theorems about the specific function above already exist in mathlib.)
Ilmārs Cīrulis (Sep 16 2025 at 02:14):
What this function should return when k < f 0?
Ching-Tsun Chou (Sep 16 2025 at 03:14):
Sorry, I made a typo: the range of the summation should be i < n. I've corrected the inequality above.
Yaël Dillies (Sep 16 2025 at 05:37):
I don't think we have anything about this specific instantiation of Nat.findGreatest, no
Ching-Tsun Chou (Sep 16 2025 at 17:12):
Thanks for the info.
Last updated: Dec 20 2025 at 21:32 UTC