Hello all,
I am a bit new to this online coding platform hence I am sorry if I am asking anything that is fairly obvious. Getting to the solution of the question: If a number has to be T-Prime, it has to be a perfect square of a prime number.
My algo: 1)check if the number is a perfect square. 2)If it is a perfect square check if the square root is a prime number.
Problem I am facing: My code is working fine for many test cases, but failing at test case 16 with an error(wrong answer 28561st lines differ — expected: 'NO', found: 'YES') The input for 28561th line is 28561(169*169). In my system it is showing "NO" (not a t prime) which is correct.
I don't know where it went wrong. Any help is appreciated. Thank you.
I accept your code!
your problem was
pow()
function because its returns double and double has error! you can compare your code with mine to see the problem:)Thank you very much. The i*i<=n, that is a new perspective for me. Once again Thank you.