When we look to hire a recent college graduate, there’s not a whole lot we can expect. Source Control, Defect Tracking, Best Practices –all concepts not a part of any computer science curriculum I’ve ever seen, but essential in any business environment. All we can hope for is a good personality match, a strong potential for learning, and at a very minimum, some retention of the concepts taught in computer science courses.

On a recent interview, Richard’s candidate managed to score zero-for-three. Despite having recently graduated with a computer science degree, the student had a tough time solving the easiest of easy computer-science riddles: the Factorial. Their conversation went something like this ...

Richard: Could you write a quick function that will find the factorial of any given number using recursion?
Graduate: I don't know what recursion is.
Richard: Ummmm....then can you solve it iteratively?
Graduate: Iteratively?
Richard: You know, like with a for-loop.
Graduate: Oh, OK, I think I can manage.

Richard let the student go off and solve the factorial problem. Fifteen minutes later, he turned in the following:

 

public int factorial(int n)
{
     int a = 0;

     for (int i = 1; i < 10; i++)
     {
          i = i * (i + 1);
          a = i;
     }

     return a;
}