VOOZH about

URL: https://www.geeksforgeeks.org/dsa/find-minimum-sum-factors-number/

⇱ Find minimum sum of factors of number - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Find minimum sum of factors of number

Last Updated : 20 Oct, 2023

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 7

Input: 105
Output: 15 

Recommended Practice

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)



Comment