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
const printFractions = ( n ) => { for ( var i = 1 ; i < n ; i ++ ) { for ( var j = i + 1 ; j <= n ; j ++ ) { if ( __gcd ( i , j ) == 1 ) { let a = ` ${ i } ` ; let b = ` ${ j } ` ; document . write ( ` ${ a } ${ b } ` ) } } } } const __gcd = ( a , b ) => { if ( b == 0 ) { return a ; } else { return __gcd ( b , a % b ) ; } } let n = 3 ; printFractions ( n ) ;