You are viewing a single comment's thread. Return to all comments →

100 points in just a millisecond:

1) find prime numbers from 1 to N. 2) find maximum power of prime number. 3) multiply each prime powers.

Hint: You dont need to calculate nonprime numbers because you always have enough primes to make them up

int result = 1; for (int i = 1; i <= n; i++) { if (isPrime(i)) { int r1 = 1; while (r1 * i <= n) r1 *= i; result *= r1; } } return result;

## Project Euler #5: Smallest multiple

You are viewing a single comment's thread. Return to all comments →

100 points in just a millisecond:

1) find prime numbers from 1 to N. 2) find maximum power of prime number. 3) multiply each prime powers.

Hint: You dont need to calculate nonprime numbers because you always have enough primes to make them up