Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- int dcm(int a,int b)
- {
- while(a!=b)
- {
- if(a>b)
- a=a-b;
- else
- b=b-a;
- }
- return a;
- }
- int main()
- {
- int a,b,produs=1,d=2,p,nrd=0,x;
- cin>>a>>b;
- x=dcm(a,b);
- while(x>1)
- {
- p=0;
- while(x%d==0)
- {
- x=x/d;
- p=p+1;
- }
- if(p>0)
- {
- produs=produs*d;
- nrd++;
- }
- d++;
- }
- if(nrd>=2)
- cout<<produs;
- else
- cout<<"nu exista";
- }
Advertisement
Add Comment
Please, Sign In to add comment