- 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

# Java Program to find minimum sum of factors of a number

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

## Example

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)); } }

## Output

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.

- 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
- Java Program to Find sum of even factors of a number
- Find minimum sum of factors of number using C++.
- C++ Program to find sum of even factors of a number?
- To find sum of even factors of a number in C++ Program?
- C Program for Find sum of odd 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
- Find sum of even factors of a number in Python 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
- Java Program to Display Factors of a Number

Advertisements