(b) For question b, we basically do the same exact thing as stated above.
First, let's review the cases for a=b=c.
There are obviously n such triplets.
Next, let's look at when exactly two are the same. You have 3 choices for which number is repeated and then n choices for the repeated number, and then n-1 for the distinct number. This gets us 3n(n-1).
Lastly, we have 3 different numbers. There are 6(n3) ways because there are 3 distinct numbers out of n and 3! = 6 ways to do this.
Thus, when we add them together, we get n+3n(n−1)+6(n3).!
Thanks! :)