Find numbers that divide X and Y to produce the same remainder | C ++ program to find numbers that divide X and Y to produce the same remainder ; Function to find the required number as M ; Finding the maximum value among X and Y ; Loop to iterate through maximum value among X and Y . ; If the condition satisfies , then print the value of M ; Driver code
#include <iostream> NEW_LINE using namespace std ; void printModulus ( int X , int Y ) { int n = max ( X , Y ) ; for ( int i = 1 ; i <= n ; i ++ ) { if ( X % i == Y % i ) cout << i << " ▁ " ; } } int main ( ) { int X , Y ; X = 10 ; Y = 20 ; printModulus ( X , Y ) ; return 0 ; }