Given a number N, you need to write a program that finds the sum of digits of the number till the number becomes a single digit and then check whether the number is Prime/Non-Prime.
Input : 5602 Output: No Step 1- 5+6+0+2 = 13 Step 2- 1+3 = 4 4 is not prime Input : 56 Output : Yes Step 1- 5+6 = 11 Step 2- 1+1 = 2 hence 2 is prime
First line of the input contains an integer T, denoting the number of test cases. Then T test case follows. The only lone of each testcase contains the integer N.
For each test case print "P" if the resultant is prime and "NP" if the number is Non-prime.
If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.