Prime Visits Wrong Ans in some test Case

Getting wrong ans in some test cases.

code
Question

Thankyou