Note that this calculates Fibonacci numbers in an iterative way, because JVM doesn’t have TCO (Tail Call Optimization) as is found in many functional languages. Implementing it recursively would result in StackOverflowError for larger numbers!