The program must accept two integer X and Y as the input.The program must print the uncommon factors of X and Y in descending order as the output.If there is no uncommon factor then the program must print '-1' as output.
EXAMPLE INPUT/OUTPUT 1:
INPUT:
24 100
OUTPUT
100 50 25 24 20 12 10 8 6 5 3
Explanation:
The factors of 24 are 1,2,3,4,6,8,12,24.
The factors of 100 are 1,2,4,5,10,20,25,50,100.
The uncommon factors are 3,5,6,8,10,12,20,24,25,50,100.So they are printed in descending order as the output.
EXAMPLE INPUT/OUTPUT 2:
INPUT:
36 36
OUTPUT
-1
CODE:
#include<stdio.h>int main() { int x,y; scanf("%d %d",&x,&y); if(x==y) { printf("-1"); return 0; } int max=(abs(x-y)+(x+y))/2; for(int i=max;i>=2;i--) { if((x%i!=0 && y%i==0)||(x%i==0 && y%i!=0)) { printf("%d ",i); } }}