Find numbers that divide X and Y to produce the same remainder | Function to print all the possible values of M such that X % M = Y % M ; Finding the absolute difference of X and Y ; Iterating from 1 ; Loop to print all the factors of D ; If i is a factor of d , then print i ; If d / i is a factor of d , then print d / i ; Driver code
function printModulus ( X , Y ) { var d = Math . abs ( X - Y ) ; var i = 1 ; while ( i * i <= d ) { if ( d % i == 0 ) { document . write ( i + " " ) ; if ( d / i != i ) document . write ( parseInt ( d / i ) + " " ) ; } i ++ ; } } var X = 10 ; var Y = 26 ; printModulus ( X , Y ) ;