Print all proper fractions with denominators less than equal to N | Function to print all proper functions ; If the numerator and denominator are coprime ; Driver code
def printfractions ( n ) : NEW_LINE INDENT for i in range ( 1 , n ) : NEW_LINE INDENT for j in range ( i + 1 , n + 1 ) : NEW_LINE 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 DEDENT DEDENT def __gcd ( a , b ) : NEW_LINE INDENT if b == 0 : NEW_LINE INDENT return a NEW_LINE DEDENT else : NEW_LINE INDENT return __gcd ( b , a % b ) NEW_LINE DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT n = 3 NEW_LINE printfractions ( n ) NEW_LINE DEDENT