2 solutions

  • 0
    @ 2022-9-20 21:30:17
    #include <stdio.h>
    int isprime(int x)
    {
        int n = sqrt(x);
        for(int i = 2; i <= n; i++){
            if(x % i == 0) return 0;
        }
        return 1;
    }
    
    int main()
    {
        int n;
        while(~scanf("%d",&n))
        {
            if(n < 2)   printf("No\n");
            else{
                if(isprime(n))  printf("Yes\n");
                else printf("No\n");
            }
        }
        return 0;
    }
    

    Information

    ID
    326
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    6
    Tags
    # Submissions
    157
    Accepted
    50
    Uploaded By