Varianta 93 / Subiectul 3 / Problema 4 |
#include<iostream.h> int dcm(int a, int b) { while(a!=b) if(a>b) a=a-b; else b=b-a; return a; } void main() { int a,b,c,d,p=1,k=0; cin>>a>>b; c=dcm(a,b); d=2; while(c!=1) if(c%d==0) { k++; p=p*d; while(c%d==0) c=c/d; } else d++; if(k>1) cout<<p; else cout<<"nu exista"; } |