Every Kotlin program has at least one function main(). However, you can define any number of functions in your program until memory is not full. It’s always a good practice to divide the whole program into smaller functions that are logically similar. It makes program more readable, understandable and debuggable.
A function declaration is done using the fun keyword.
The basic syntax of a function in Kotlin looks like this:
Syntax of for loop