Carmichael Numbers
Submissions: 1505   Accuracy:

17.67%

  Difficulty: Medium   Marks: 4

A number n is said to be a Carmichael number if it satisfies the following modular arithmetic condition:

  power(b, n-1) MOD n = 1, 
  for all b ranging from 1 to n such that b and 
  n are relatively prime, i.e, gcd(b, n) = 1 

Given a positive integer n, find if it is a Carmichael number.

Input:

First line of input contains the number of test cases.

Only line of each test case contains the number n.


Output:
Print "Yes" if the number is a Carmichael number else "No" without quotes.

Constraints:

1<=T<=100

1<=N<=100000


Example:

Sample Input:

1
8

Sample Output:
No

Explanation :
8 is not a Carmichael number because 3 is relatively prime to 8 and

(38-1) % 8 = 2187 % 8 is not 1.

** For More Input/Output Examples Use 'Expected Output' option **

Author: jain_rishabh


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.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.


to report an issue on this page.