Perhaps it's recursion where Mecnels is struggling with.
A very easy example of an recursive function:
Desiging a recursive function consists of two steps. First there must be an end-step.
int fac (int n)
if (n == 1)
return (n * fac (n -1));
n! = n x (n -1) x (n-2) x .. x 2 x 1
You can see, if (n == 1), then the end is reached. In each other case, you have to perform the recursion step. In this example it is easy to see that:
n! = n x (n - 1)!
n! = n x (n - 1) x (n - 2)!
So the recursion step is:
n x (n - 1)!
Or in C:
n x fac (n - 1)