Smallest positive integer X satisfying the given equation | C # program to implement the above approach ; Function to find out the smallest positive integer for the equation ; Stores the minimum ; Iterate till K ; Check if n is divisible by i ; Return the answer ; Driver Code
using System ; class GFG { static int findMinSoln ( int n , int k ) { int minSoln = int . MaxValue ; for ( int i = 1 ; i < k ; i ++ ) { if ( n % i == 0 ) minSoln = Math . Min ( minSoln , ( n / i ) * k + i ) ; } return minSoln ; } public static void Main ( String [ ] args ) { int n = 4 , k = 6 ; Console . WriteLine ( findMinSoln ( n , k ) ) ; } }