Prime Visit Failing 3rd Test Case

My code works fine for the first two test cases but it is failing for the third one. I cannot figure out the problem.
https://ide.codingblocks.com/s/67963

@tomarvikas738 there is small modification in your code you need to optimise it further .i have corrected your code you can refer this.