1 solutions

  • 0
    @ 2025-11-5 15:44:18

    C++ :

    #include<bits/stdc++.h>
    using namespace std;
    long long n,a[1000000];
    int main()
    {
    	a[1]=1;
    	cin>>n;
    	for(int i=2;i*i<=n;i++)
    	{
    		if(a[i]==0)
    		{
    			for(int j=i+i;j<=n;j+=i)
    			    a[j]=1;
    		}
    	}
    	if(a[n])
    	    cout<<"No";
    	else
    	    cout<<"Yes";
    	
    	return 0;
    }
    

    Pascal :

    var
      a,i:longint;
      b:boolean;
    begin
      b:=false;
      readln(a);
      for i:=2 to a-1 do
      if a mod i=0 then begin
      b:=true;
      break;
      end;
      if (b) or (a=1) then write('No')
      else write('Yes');
    end.
    
    • 1

    Information

    ID
    17108
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    (None)
    Tags
    # Submissions
    0
    Accepted
    0
    Uploaded By