public int Partition1 {get;set;}
public int Partition1 {get;set;}
private void SetPartitions(List<int> primeNumbers)
{
this.Partition1 = // get the product of the prime numbers closest to 10000
this.Partition2 = // get the product of the remaining prime numbers
}
SetPartitions method accepts an array of prime numbers such as 2, 3, 5, 2851, 13.
In the above example, it should assign:
this.Partition1 = 2851 * 3; // which is 8553 and closest possible to 10000
this.Partition2 = 2 * 5 * 13;
How to implement the logic?
997 is the largest prime number between 1 to 1000. TrueTrue – 997 is the largest prime number between 1 to 1000.
2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199.
The number 10000 has 23 factor not counting 1 or itself makeing it a square and maybe composite. Prime Factors for the number 10000 = (24 × 54) or(2 × 2 × 2 × 2 × 5 × 5 × 5 × 5).
Then go through each number from 10,000 to 2. For each of these, test to see if the prime factorization of the number is a subset of the given list. If it is, then we have found the answer.
Partition1
is the prime factors of the number. Partition2
is simply primeNumbers - Partition1
.
Here's the psuedocode:
for n=10000 to 2
factors = prime_factorization(n)
if( factors is subset primeNumbers ) {
partition1 = factors
partition2 = primeNumbers - factors
return (partition1,partition2)
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With