Math, asked by Anonymous, 8 months ago

Find the sum of all natural numbers n such that

lcm(1,2,3,4,......,n)= n!

Answers

Answered by Anonymous
2

Step-by-step explanation:

we know if LCM(a, b) = X so any prime factor of a or b will also be the prime factor of ‘X’.

Initialize lcm variable with 1

Generate all prime number less then 10^6 and store in Array prime by using Sieve of Eratosthenes.

Find the maximum number which is less than the given number and equal to power of the prime.

Then multiply this number with lcm variable.

Repeat step 3 and 4 until prime is less than the given number.

Similar questions