ValerianBenchea

Numar prim

Jan 15th, 2020
279
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.28 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.     int n, d=2, p=0;
  7.     cout<<"n="; cin>>n;
  8.     for(d; d<=n/2; d++)
  9.         if(n%d==0)
  10.             p++;
  11.     if(p!=0)
  12.         cout<<"Numarul nu este prim";
  13.     else
  14.         cout<<"Numarul este prim";
  15.  
  16.     return 0;
  17. }
Advertisement
Add Comment
Please, Sign In to add comment