SelinD

V93s3ex4

Apr 2nd, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3.  
  4. int dcm(int a,int b)
  5. {
  6. while(a!=b)
  7. {
  8. if(a>b)
  9. a=a-b;
  10. else
  11. b=b-a;
  12. }
  13. return a;
  14. }
  15.  
  16. int main()
  17. {
  18. int a,b,produs=1,d=2,p,nrd=0,x;
  19. cin>>a>>b;
  20. x=dcm(a,b);
  21. while(x>1)
  22. {
  23. p=0;
  24. while(x%d==0)
  25. {
  26. x=x/d;
  27. p=p+1;
  28. }
  29. if(p>0)
  30. {
  31. produs=produs*d;
  32. nrd++;
  33. }
  34. d++;
  35. }
  36. if(nrd>=2)
  37. cout<<produs;
  38. else
  39. cout<<"nu exista";
  40. }
Advertisement
Add Comment
Please, Sign In to add comment