Well you don't define all terms, but I'm assuming that some valid triangles for S(10) are

Code:3Code:1 2 3 4 5 6Code:6 1 2Where the last two are considered distinct.Code:6 2 1

With notation C(n,k) for binomial coefficient (that is, n choose k) and P(n,k) the number of ordered k-subsets of {1,...,n}; thus P(n,k) = C(n,k)*k!

Then the number of triangles from S(n) is T(n)=P(n,1)+P(n,3)+P(n,6)+... not letting k exceed n in P(n,k), and where the sequence of k is the triangle numbers 1,3,6,10,15,...