Change your for loop to this:
for( n=2; n<num; n++ )
That'll solve your problem.
Explanation: Since you've already determined that 1 or 2 will give you a 1, start your loop @ 2. Loop through until n becomes larger than the entered number. This will solve the problem you were having.