0

Can someone help me about this code?

I want to make a program that finds least common multiple(LCM). I made a part of code, trying to print the first row of wanted result, but I went over time limit. Here is thge code: https://code.sololearn.com/cioO2R6wFG4a/?ref=app

6th Jun 2018, 2:29 PM
Урош
2 Answers
+ 3
your last to functions are really hard to read because the naming of stuff is not very transparent using prime factorization is very inefficent, i recomment you use the euclidean algorithm to calculate the gcd and use lcm(a,b)=a*b/gcd(a,b) and the fact that gcd(a,b,c) = gcd(a,gcd(b,c)) you can find the primes faster using the sieve of eratosthenes. don‘t take the time limit here to serious, try it on a computer
6th Jun 2018, 2:48 PM
Max
Max - avatar
0
Thank you, I didn't think about these formulas. Nice to hear smart answers.
6th Jun 2018, 4:49 PM
Урош