Fermat's polygonal number theorem
Haskell, 78 80 77 bytes

We compute the cartesian product of the first \$n\$ s-gonal numbers, and then find the first entry that sums to \$n\$.



s#n=[x|x&lt;-mapM(map(\n-&gt;s*(n^2-n)`div`2+n*(2-n)))([0..n]&lt;$[1..s]),sum x==n]!!0


Try it online!