problem:RECIPE Problem - CodeChef
my solution:CodeChef: Practical coding for everyone
You are supposed to find the gcd of the numbers entered in one test case.
Your logic is correct, there’s just a very little mistake.
Just assign st=0 as given below in the loop of the variable i:
for(j=x;j>0;j--)
{
st=0;
for(i=0;i<n;i++)
{
if(a[i]%j==0)
st=st+1;
if(st==n)
y=1;
}
if(y==1)
break;
}
Here’s the link to my submissions of this question, CodeChef: Practical coding for everyone
If you still have any problem you can comment below.