# Help me in solving APPLEORANGE problem

### My issue

include <stdio.h>

int main() {
int a, b, c, d, f;
scanf(“%d”, &a);

``````for (b = 1; b <= a; b++) {
scanf("%d", &c);
scanf("%d", &d);

for (f = c; d % f == 0; f--) {
printf("%d\n", f);
}
}

return 0;
``````

}
sigpfe error reason

### My code

``````#include <stdio.h>

int main() {
int a, b, c, d, f;
scanf("%d", &a);

for (b = 1; b <= a; b++) {
scanf("%d", &c);
scanf("%d", &d);

for (f = c; d % f == 0; f--) {
printf("%d\n", f);
}
}

return 0;
}

``````

Learning course: Number theory
Problem Link: CodeChef: Practical coding for everyone

@eeshsaxena
your logic and implementation is not right.
plzz refer the following c solution .

``````#include <stdio.h>

int main(void) {
int t;
scanf("%d",&t);
while(t--)
{  int a,b;
scanf("%d%d",&a,&b);
while(a!=b)
{
if(a>b)
a=a-b;
if(a<b)
b=b-a;
}
printf("%d\n",a);

}

return 0;
}``````

include <stdio.h>

int main() {
int a, c, d,g,count;
scanf(“%d”, &a);

``````for (int b = 1; b <= a; b++) {
scanf("%d", &c);
scanf("%d", &d);
int f=c;

if (d%c!=0)
while (d%f!=0)
{

f--;
g=c-f+1;
printf("%d\n",g);
count++;

}
else {
printf("%d\n",c);
}

}

return 0;
``````

}