Firstly, why do you use m+1
for the x in range()
? Note, you might want to only use range(2, m/2, 1)
- see if you can figure out why.
Secondly,
if m % x == 0:
if Prime(m) != 0:
l.append(x)
If m
is divisible by x
then it can't be prime and calling Prime(m)
is useless. I suspect you meant to pass x
as the argument. (Assuming x
is not 0 or == m
)
Thirdly Prime()
never returns anything. This means that it is always != 0
.
Finally, to help you out a bit, I'll link you to some of my own answers to this question.