Modify N by adding its smallest positive divisor exactly K times | Function to find the smallest divisor of N greater than 1 ; If i is a divisor of N ; If N is a prime number ; Function to find the value of N by performing the operations K times ; If N is an even number ; Update N ; If N is an odd number ; Update N ; Driver Code
def smallestDivisorGr1 ( N ) : NEW_LINE INDENT for i in range ( sqrt ( N ) ) : NEW_LINE INDENT i += 1 NEW_LINE DEDENT if ( N % i == 0 ) : NEW_LINE INDENT return i NEW_LINE DEDENT return N NEW_LINE DEDENT def findValOfNWithOperat ( N , K ) : NEW_LINE INDENT if ( N % 2 == 0 ) : NEW_LINE INDENT N += K * 2 NEW_LINE DEDENT else : NEW_LINE INDENT N += smallestDivisorGr1 ( N ) + ( K - 1 ) * 2 NEW_LINE DEDENT return N NEW_LINE DEDENT N = 6 NEW_LINE K = 4 NEW_LINE print ( findValOfNWithOperat ( N , K ) ) NEW_LINE