Problem Statement
A famous mathematical conjecture states that all numbers greater than 5 can be expressed as the sum of 3 prime numbers. A number is prime if it is only evenly divisible by itself and 1. Furthermore, 2 is the lowest prime number. Given an integer k greater than 5, you will return the 3 prime numbers whose sum is k in increasing order. If there is more than one combination of three primes whose sum is k return the 3 primes with the highest product (i.e., the three primes multiplied together produces the highest value).
Definition
- Class:
- GoldConjecture
- Method:
- numbers
- Parameters:
- int
- Returns:
- int[]
- Method signature:
- int[] numbers(int k)
- (be sure your method is public)
Constraints
- k will be between 6 and 2000 inclusive
- All given values of k will have solutions
Examples
10
Returns: { 2, 3, 5 }2,3,5 is the only solution that works.12
Returns: { 2, 5, 5 }2,3,7 and 2,5,5 both are primes that add up to 12 but: 2*3*7 = 42 2*5*5 = 50 So the solution is {2,5,5}2000
Returns: { 2, 977, 1021 }1997
Returns: { 659, 661, 677 }777
Returns: { 257, 257, 263 }6
Returns: { 2, 2, 2 }