I have a problem with reducing two rational numbers in the form a/b and need to recude them to form where a and b do not have any common integer dividers.

I tried something, but it didn't work. Here is the code:

Code:
#include <stdio.h>
int main()
{
int i, j, k;
int a, b;
scanf("%d/%d", &a, &b);
if(a > b) j = b;
else j = a;
for(i = j;i > 1; i--)
{
if(((a % j) == 0) && ((b % j) == 0)) { k = j; break; }
}
a = a / j;
b = b / j;
printf("%d/%d\n", a, b);
return 0;
}
It always gives me result 1/1. Where is the problem ? I really can't figure it out.
Thanks in advance.