Why is the concept of function used in the solution provided by you although we have not been taught that?
Concept of Function
@Syed-Siddiqui-2497215583854102,
Even if the code is in a different function, it won’t change the answer or the logic. All you need to do it take input of n in the main function and copy the code given in the solution inside your main function.
You will be taught functions soon, don’t worry about that. 