How about brute force? This consists of $O(n^3)$ steps (the verification of positive integers $x,\, y,\, z\, $ s. t. $x+y+z \le n$) in your case.
user64494
- 3.5k
- 14
- 22