Find numbers that divide X and Y to produce the same remainder | Java program to 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
import java . util . * ; class GFG { static void printModulus ( int X , int Y ) { int d = Math . abs ( X - Y ) ; int i = 1 ; while ( i * i <= d ) { if ( d % i == 0 ) { System . out . print ( i + " ▁ " ) ; if ( d / i != i ) System . out . print ( d / i + " ▁ " ) ; } i ++ ; } } public static void main ( String [ ] args ) { int X = 10 ; int Y = 26 ; printModulus ( X , Y ) ; } }