- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

Here we will see how to get a minimum sum of factors of a given number. Suppose a number is 12. We can factorize this in different ways −

- 12 = 12 * 1 (12 + 1 = 13)
- 12 = 2 * 6 (2 + 6 = 8)
- 12 = 3 * 4 (3 + 4 = 7)
- 12 = 2 * 2 * 3 (2 + 2 + 3 = 7)

The minimum sum is 7. We will take a number, and try to find the minimum factor sum. To get the minimum factor sum, we have to factorize the number as long as possible. In other words, we can say if we try to find the sum S by adding prime factors, then the sum will be minimized.

#include<iostream> using namespace std; int primeFactorSum(int n) { int s = 0; for (int i = 2; i * i <= n; i++) { while (n % i == 0) { s += i; n /= i; } } s += n; return s; } int main() { int n = 12; cout << "Minimum sum of factors: " << primeFactorSum(n); }

Minimum sum of factors: 7

- Related Questions & Answers
- Python Program for Find minimum sum of factors of number
- C Program to Find the minimum sum of factors of a number?
- Find sum of even factors of a number using C++.
- Find sum of odd factors of a number using C++.
- Java Program to find minimum sum of factors of a number
- C++ Program to find sum of even factors of a number?
- C Program for Find sum of odd factors of a number?
- C++ program for Find sum of odd factors of a number
- To find sum of even factors of a number in C++ Program?
- Python Program for Find sum of even factors of a number
- Python Program for Find sum of odd factors of a number
- Find sum of even factors of a number in Python Program
- Java Program to Find sum of even factors of a number
- How to Find Factors of Number using Python?
- Product of factors of number in C++

Advertisements