
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
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
Find Minimum Sum of Factors of a Number in Python
In this article, we will learn about the solution to the problem statement given below −
Problem statement
Given a number input , find the minimum sum of factors of the given number.
Here we will compute all the factors and their corresponding sum and then find the minimum among them.
So to find the minimum sum of the product of number, we find the sum of prime factors of the product.
Here is the iterative implementation for the problem −
Example
#iterative approach def findMinSum(num): sum_ = 0 # Find factors of number and add to the sum i = 2 while(i * i <= num): while(num % i == 0): sum_ += i num /= i i += 1 sum_ += num return sum_ # Driver Code num = 12 print (findMinSum(num))
Output
7
All the variables are declared in the global frame as shown in the figure given below −
Conclusion
In this article, we learned about the approach to Find the minimum sum of factors of a number.
Advertisements