# Python Program for Find minimum sum of factors of number

Given a number, find minimum sum of its factors.
Examples:

`Input : 12Output : 7Explanation: 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 : 105Output : 15`

## Python3

 `# Python program to find minimum``# sum of product of number` `# To find minimum sum of``# product of number` `def` `find_min_sum(num):``    ``min_sum ``=` `num``    ` `    ``for` `i ``in` `range``(``2``, ``int``(num``*``*``0.5``) ``+` `1``):``        ``if` `num ``%` `i ``=``=` `0``:``            ``factor ``=` `num ``/``/` `i``            ``min_sum ``=` `min``(min_sum, i ``+` `factor)``    ` `    ``return` `min_sum` `# driver code``number ``=` `16` `# Call the function and print the result``result ``=` `find_min_sum(number)``print``(``"The minimum sum of factors for"``, number, ``"is"``, result)`  `# This code is contributed by AYUSH MILAN`

Output:

`8`

Time Complexity: O(n1/2 * log n)

Auxiliary Space: O(1)
Please refer complete article on Find minimum sum of factors of number for more details!

Previous
Next