Pappu19

Prime Number

Dec 8th, 2021 (edited)
463
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.36 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.     int n,i;
  7.  
  8.     cout<<"Enter number: "<<"\n";
  9.     cin>>n;
  10.  
  11.     for(i=2; i<n; i++)
  12.     {
  13.         if(n%i == 0)
  14.         {
  15.             cout<<"Not Prime!!";
  16.             return 0;
  17.         }
  18.     }
  19.     if(i == n || n == 1)
  20.     {
  21.         cout<<"Prime";
  22.     }
  23.     else
  24.         cout<<"Not prime";
  25. }
  26.  
Add Comment
Please, Sign In to add comment