Hello and welcome to CodeReviewCode Review.
Surprisingly, a, b, and c are probably the best variable names you can come up with. They are conventionally given as canonical examples of bad names, but when the task is to implement a mathamaticalmathematical function using the same variable names as in the spec is more important.
As to the single loop question, the short answer is "not easily". You are trying to check all combinations of three independently varying things. That means you naturally want three loops, and anything else would lose out on readability.
Aside from your questions, I have a few observations about this code that might be worth fixing.
- When you have a loop that is counting up to something, it is convention to prefer a
forloop to awhileloop. Factorialis what is known as a "pure function" which means that its output only depends on its input. Such functions within loops are often good candidates for caching so that you don't have to waste time calculating the same output a hundred and eleven times for each input number.- Both +
+and **are commutative, which means that if a, b, and c pass then b, a, and c also pass. You should check whether you need to display all reorderings of the same sets of numbers. - It is unclear where 11 has come from. It seems like a magic number, which would benefit from being moved to a named constant and having a comment explaining why that value is used.