- Related Questions & Answers
- C Program to Find the minimum sum of factors of a number?
- Python Program for Find minimum sum of factors of number
- Find minimum sum of factors of number using C++.
- Java Program to Find sum of even 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?
- Python Program for Find sum of even factors of a number
- Python Program for Find sum of odd factors of a number
- C++ program for Find sum of odd factors of a number
- Find sum of even factors of a number in Python Program
- To find sum of even factors of a number in C++ Program?
- Find sum of even factors of a number using C++.
- Find sum of odd factors of a number using C++.
- Java Program to find Product of unique prime factors of a number
- C/C++ Program to find Product of unique prime factors of a number?

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

To find minimum sum of factors of a number, the Java code is as follows −

public class Demo { static int minimum_sum(int num){ int my_sum = 0; for (int i = 2; i * i <= num; i++){ while (num % i == 0){ my_sum += i; num /= i; } } my_sum += num; return my_sum; } public static void main(String[] args){ int num = 350; System.out.println("The minimum sum of factors of the number are "); System.out.println(minimum_sum(num)); } }

The minimum sum of factors of the number are 19

A class named Demo contains a static function named ‘minimum_sun’, that initializes a sum to 0, and iterates through the number and checks to find the minimum sum from all the factors of that specific number. In the main function, the value for the number is defined, and the function is called by passing the number as the parameter. Relevant message is displayed on the console.

Advertisements