3 solutions

  • 3
    @ 2024-8-21 16:22:28
    #include<bits/stdc++.h>
    using namespace std;
    bool isPrime(int y)
    {	if(y<2)
    	{
    		return false;
    	}
    	for(int i=2;i<=y/i;i++)
    	{
    		if(y%i==0)
    		{
    			return false;
    		}
    	}
    			return true;
    			
    }
    int main()
    {
        int n;
        cin>>n;
        if(isPrime(n))	cout<<"yes";
        else cout<<"no";
        return 0;
    }
    
    • 1
      @ 2025-12-28 11:52:53
      #include<bits/stdc++.h>
      using namespace std;
      bool q(int n)
      {
          if(n<2) return false;
          int c=0;
          for(int i=2;i*i<=n;i++)
          {
              if(n%i==0) c++;
          }
          if(c==0) return true;
          else return false;
      }
      int main()
      {
          int n;cin>>n;
          if(q(n)) cout<<"yes";
          else cout<<"no";
          return 0;
      }
      
      • 0
        @ 2026-7-22 10:45:40
        #include <bits/stdc++.h>
        using namespace std;
        bool q(int n)
        {
        	if(n<2) return false;
        	int c=0;
        	for(int i=2;i*i<=n;i++)
        	{
        		if(n%i==0) c++;
        	}
        	if(c==0) return true;
        	else return false;
        }
        int main()
        {
        	int n;
        	cin>>n;
        	if(q(n)) cout<<"yes";
        	else cout<<"no";
        	return 0;
        }
        • 1

        Information

        ID
        109
        Time
        1000ms
        Memory
        256MiB
        Difficulty
        1
        Tags
        (None)
        # Submissions
        122
        Accepted
        37
        Uploaded By