For n=40, the expression doesn't generate a prime. But you're right that this is more obvious for n=41, as 41 can be factored out of the expression in this case.