Smallest positive integer X satisfying the given equation | Python3 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
import sys NEW_LINE def findMinSoln ( n , k ) : NEW_LINE INDENT minSoln = sys . maxsize ; NEW_LINE for i in range ( 1 , k ) : NEW_LINE INDENT if ( n % i == 0 ) : NEW_LINE INDENT minSoln = min ( minSoln , ( n // i ) * k + i ) ; NEW_LINE DEDENT DEDENT return minSoln ; NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT n = 4 ; NEW_LINE k = 6 ; NEW_LINE print ( findMinSoln ( n , k ) ) ; NEW_LINE DEDENT