Find the minimum prime factor of a given integer(n) and return the difference of ‘n’ with its minimum prime factor.
Prime factor: The prime numbers that divide an integer exactly are called its prime factors.
Assumption: n>1
Note: 1 is not a prime number.
Example 1:
Input:
350
Output:
348
Explanation:
350 = 2 x 5 x 5 x 7, therefore prime factors of 350 are 2, 5 and 7.
Since 2 is the minimum prime factor of 350, difference = 350-2 = 348.
Thus, the output is 348.
Example 2:
Input:
1771
Output:
1764
Solution: In Python3
n=int(input())
l=[]
i=2
temp=n
while(i<=n):
if n%i==0:
l.append(i)
n=n//i
else:
i+=1
print(temp-min(l))