BETWEEN TWO SETS-HACKERRANK

PROBLEM STATEMENT :
You will be given two arrays of integers and asked to determine all integers that satisfy the following two conditions:
  1. The elements of the first array are all factors of the integer being considered
  2. The integer being considered is a factor of all elements of the second array
EXPLANATION:
These numbers are referred to as being between the two arrays. You must determine how many such numbers exist.
For example, given the arrays a=[2,6],b=[24,36] there are two numbers 6,12 such that 6%2=0 , 6%6=0 ,24%6=0,36%6=0 similarly for 12 12%2=0,12%12=0,24%12=0,36%12=0
Hence the process to do this is to find l.c.m of first array
G.C.D of second array Find number of factors for g.c.d/l.c.m
PROCEDURE TO FIND G.C.D

int gcd(int n1, int n2)
{
if (n2 != 0)
return gcd(n2, n1%n2);
else
return n1;
}
PROCEDURE TO FIND L.C.M
int LCM(int n1,int n2)
{
return (n1*n2)/gcd(n1,n2);
}
NOW Find factors of gcd divided by lcm
int lcm1=1,gcd1=1,i,n1,n2,count;
int array1[10],array2[10];
scanf("%d",&n1);
for((i=n1-1;i>=0;i--)
{
scanf("%d",&array1[i]);
lcm1=LCM(array1[i],lcm1);
}
scanf("%d",&n2);
for(i=n2-1;i>=0;i--)
{
scanf("%d",&array2[i]);
gcd1=GCD(array2[i],gcd1);
}
count=0;
for(i=0;i
if(gcd1%i= = 0)
count+=1;
printf("%d",count);
This code prints number of digits satisfy the given condition.
HOPE THIS HELPS..