Smallest positive integer X satisfying the given equation | 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
function findMinSoln ( n , k ) { var minSoln = 1000000000 ; for ( var i = 1 ; i < k ; i ++ ) { if ( n % i == 0 ) minSoln = Math . min ( minSoln , ( n / i ) * k + i ) ; } return minSoln ; } var n = 4 , k = 6 ; document . write ( findMinSoln ( n , k ) ) ;