r/PythonLearning • • Aug 27 '25

Help

Post image

Where is the problem

17 Upvotes

22 comments sorted by

View all comments

1

u/Drakhe_Dragonfly Aug 27 '25

I'm not entirely sure, but I think that X mod 1 is always 0, that's why it doesn't gives you the correct result.

Also, instead of n for the upperbound up to which you check, you can take n/2 (technically you could go down to the sqareroot of n without any problems, but that's optional)