Programs are very useful for the purpose of solving problems. Many
programmers know this potential of programs, and use it to their advantage.
However, all is not so straight-forward in the world of programming and
problem-solving; there are as many ways to go about finding a solution as there
are stars in the sky (perhaps more!).
All in all, the method by which you code a program for finding the solution
to a problem is up to the programmer -- you. That is why it is important to
learn some of the basic ways by which one can arrive at a solution. Only after
you understand these ways, can you move on to more complicated problem-solving.
Before we begin, please note that open and close brackets, i.e.
"[" and "]" respectively, will contain raw code.
Decrementing Function
The first method is the decrementing function. A decrementing function
starts with a non-negative value, which is decreased each time the program
repeats the function's loop. The function will loop so long as the starting
value is non-negative, but once it is equal to or less than 0, it will
terminate.