Given an integer N( 2 <= N <= 10^9 ), split the number into one or more parts(possibly none), where each part must be greater than 1. The task is to find the minimum possible sum of the second largest divisor of all the splitting numbers.
Input : N = 27 Output : 3 Explanation : Split the given number into 19, 5, 3. Second largest divisor of each number is 1. So, sum is 3. Input : N = 19 Output : 1 Explanation : Don't make any splits. Second largest divisor of 19 is 1. So, sum is 1
The idea is based on Goldbach’s conjecture.
- When the number is prime, then the answer will be 1.
- When a number is even then it can always be expressed as a sum of 2 primes. So, the answer will be 2.
- When the number is odd,
- When N-2 is prime, then the number can be express as the sum of 2 primes, that are 2 and N-2, then the answer will be 2.
- Otherwise, the answer will always be 3.
Below is the implementation of the above approach:
Time complexity: O(sqrt(N))
- Break a number such that sum of maximum divisors of all parts is minimum
- Split the number into N parts such that difference between the smallest and the largest part is minimum
- Find the largest good number in the divisors of given number N
- Split a number into 3 parts such that none of the parts is divisible by 3
- Find sum of inverse of the divisors when sum of divisors and the number is given
- Find sum of divisors of all the divisors of a natural number
- Find largest sum of digits in all divisors of n
- Find the number of ways to divide number into four parts such that a = c and b = d
- Count number of ways to divide a number in 4 parts
- Break the number into three parts
- Divide a number into two parts
- Divide a big number into two parts that differ by k
- Partition a number into two divisble parts
- Possible cuts of a number such that maximum parts are divisible by 3
- Divide number into two parts divisible by given numbers
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.