You don't ever return the return value of the recursive call:
if x % n == 0:
#print "passed {}".format(n)
return recursive_factor_test(x,n-1)
When you omit the return
statement there, your function ends without a return statement, thus falling back to the default None
return value.
With the return
there, it works:
>>> print recursive_factor_test(5040,7)
True
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…