If the numerator and denominator are coprime
if __gcd ( i , j ) == 1 : NEW_LINE INDENT a = str ( i ) NEW_LINE b = str ( j ) NEW_LINE print ( a + ' / ' + b , end = " , ▁ " ) NEW_LINE DEDENT def __gcd ( a , b ) : NEW_LINE INDENT if b == 0 : NEW_LINE DEDENT return a NEW_LINE INDENT else : NEW_LINE DEDENT return __gcd ( b , a % b ) NEW_LINE