![]() |
VOOZH | about |
Given a number N, the task is to find minimum sum of its factors.
Examples:
Input: 12
Output: 7
Explanation:
Following are different ways to factorize 12 andsum of factors in different ways.12 = 12 * 1 = 12 + 1 = 1312 = 2 * 6 = 2 + 6 = 812 = 3 * 4 = 3 + 4 = 712 = 2 * 2 * 3 = 2 + 2 + 3 = 7Therefore minimum sum is 7Input: 105
Output: 15
Approach:
To minimize sum, we must factorize factors as long as possible. With this process, we . So to find minimum sum of product of number, we find sum of prime factors of product.
Output:
7
Time Complexity : O(n1/2 * log n)
Auxiliary Space: O(1)