This question has sparked debate for centuries, but the answer depends on what you mean by math.
If by math you mean the patterns, structures, and relationships built into the Material World, then math was discovered. Those patterns existed before anyone noticed them, named them, or wrote them down. Two rocks and two shells made four long before humans created numerals or equations.
But if by math you mean the symbols, notation, and systems of thought used to describe those patterns, then math was invented. Numbers, formulas, proofs, and equations belong to the realm of ideas. They are not the world itself, but mental constructs used to describe and organize what minds encounter in the world.
This fits well with the Idea of Ideas explored in chapter 18 of 30 Philosophers. In some ways, it resembles Kant’s Transcendental Idealism in that both recognize a distinction between the world itself and our experience or description of it. But the Idea of Ideas is framed more pragmatically through TST’s split between the Material World and Ideas about it. It then goes a step further by sorting ideas into empirical ideas, grounded in observation and measurement, rational ideas, grounded in logic and valid inference, and irrational ideas, which lack sufficient grounding in evidence or coherent reasoning. In that way, it loosely echoes Hume’s Fork, which also tried to separate stronger ideas from weaker ones by asking how well they connect to experience and reason.
Math, by this view, is part of the world of ideas, but it is a special kind of idea. It is a rational system minds develop to describe patterns and relations that are genuinely present in the Material World. Even highly abstract math ultimately grows out of impressions, patterns, and relationships first encountered in experience, then extended through reason into more formal systems.
So, was math discovered or invented? In a very real sense, both. The underlying structures and relations were there to be discovered. The language and symbolic systems used to describe them were invented. In the Idea of Ideas, this is the concept of latent ideas:
Ideas (models, patterns and truths) are present in reality before they are noticed, named, or formalized.
Imagine standing on a beach and seeing two rocks next to two shells. The world presents a relationship. We did not invent the underlying pattern. We invented the symbols and language used to describe it. Math is one of the most powerful ways minds map the order already present in reality.