Java Program to Find minimum sum of factors of number Last Updated : 05 Dec, 2018 Summarize Comments Improve Suggest changes Share Like Article Like Report Given a number, find minimum sum of its factors. Examples: Input : 12 Output : 7 Explanation: Following are different ways to factorize 12 and sum of factors 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 Therefore minimum sum is 7 Input : 105 Output : 15 Java // Java program to find minimum // sum of product of number public class Main { // To find minimum sum of // product of number static int findMinSum(int num) { int sum = 0; // Find factors of number // and add to the sum for (int i = 2; i * i <= num; i++) { while (num % i == 0) { sum += i; num /= i; } } sum += num; // Return sum of numbers // having minimum product return sum; } // Driver program to test above function public static void main(String[] args) { int num = 12; System.out.println(findMinSum(num)); } } Output: 7 Please refer complete article on Find minimum sum of factors of number for more details! Comment More infoAdvertise with us Next Article Minimum product modulo N possible for any pair from a given range K kartik Follow Improve Article Tags : Java Practice Tags : Java Similar Reads Java Program to Find sum of even factors of a number Given a number n, the task is to find the even factor sum of a number. Examples: Input : 30 Output : 48 Even dividers sum 2 + 6 + 10 + 30 = 48 Input : 18 Output : 26 Even dividers sum 2 + 6 + 18 = 26 Let p1, p2, ⦠pk be prime factors of n. Let a1, a2, .. ak be highest powers of p1, p2, .. pk respect 3 min read Java program for Find sum of odd factors of a number Write a java program for a given number n, the task is to find the odd factor sum. Examples: Input: n = 30Output: 24Explanation: Odd dividers sum 1 + 3 + 5 + 15 = 24 Input: 18Output: 13Explanation: Odd dividers sum 1 + 3 + 9 = 13 Java program for Find sum of odd factors of a number using Prime facto 3 min read Minimum product modulo N possible for any pair from a given range Given three integers L, R, and N, the task is to find the minimum possible value of (i * j) % N, where L ? i < j ? R. Examples: Input: L = 2020, R = 2040, N = 2019Output: 2Explanation: (2020 * 2021) % 2019 = 2 Input: L = 15, R = 30, N = 15Output: 0Explanation: If one of the elements of the pair i 5 min read Java Program to Perform the Unique Factorization of a Given Number Given a number n, the task is to write an efficient program to print all unique prime factors of n. Example Input: 12 Output: 2, 3 Explanation: All prime factors or 12 are 2, 2, 3. In those factors, unique factors are 2 and 3. Input: 315 Output: 3, 5, 7 Steps to find all prime factors 1) While n is 6 min read Java Program to Minimize the Maximum Element of an Array Given two integers N and K. Create an array of N positive integers such that the sum of all elements of the array is divisible by K and the maximum element in the array is the minimum possible. You have to find the Maximum element of that array. Example: Input : N=5, K=11 Output : 3 Explanation : We 4 min read Perfect Number Program in Java Using While Loop The number which is equal to the sum of its divisors is called a perfect number. Read the entered long number, assigned to the long variable n. While loop iterates until the condition (i<=n/2) is false. If the remainder of n/i=0 then add i value to the sum and increase the i value. After all the 2 min read Like