Ejemplo n.º 1
1
 /**
  * This method obtains a list of primes until the number and calculates the maximum power of each
  * prime present in the least common multiple.
  *
  * @param number The required argument, upto which the numbers be processed.
  * @return The solution obtained by optimization.
  */
 public static long cacheAndConquer(long number) {
   long product = 1;
   long limit = (long) sqrt(number);
   long[] primes = Primes.getPrimesUntil(Math.toIntExact(number));
   for (long prime : primes) {
     long power = 1;
     if (prime <= limit) {
       // The maximum power of this prime :
       power = (long) (log(number) / log(prime));
     }
     product *= (long) pow(prime, power);
   }
   return product;
 }