What is the difference between iteration
and recursion
and why/when is one better:
while (true) {
// Iterating
}
Recursion and iteration are different ways to think about a solution. It would be dificult to explain in depth the difference in full scope. In your sample code, you aleady showed the difference. Recursive function is the one that calls itself, while iterative is the one that loops through some block of code. Here are some articles to help you understand them better: Recursion wiki
Iteration wiki
CodeProject SO #1
SO #2