Advertisement
STANAANDREY

pb19XI2018

Nov 19th, 2018
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.38 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main(){
  6.     unsigned n,p,d,ok=1,i=0;
  7.     cout<<"n=";cin>>n;
  8.     cout<<"p=";cin>>p;
  9.     d=2;
  10.     while (d<=p/2&&ok==1)
  11.     {
  12.         if (p%d==0)
  13.             ok=0;
  14.         d++;
  15.     }
  16.     if (ok){
  17.   while (n%p==0)
  18.   {
  19.       n/=p;
  20.       i++;
  21.   }
  22.   cout<<p<<" apare de "<<i<<" ori in descompunere";
  23.     }
  24. //*/}
  25. return 0;}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement