Spoj divisibility problem

Revision en1, by motatoes, 2019-08-23 21:35:41

Hi Codeforces

I have been trying to solve this problem on SPOJ: https://www.spoj.com/problems/EASYMATH/

My bruteforce solution is ofcourse TLE'd and I came across this solution: https://github.com/Emsawy/Competitive-Programming/blob/master/SPOJ/EASYMATH.cpp

I have difficulty understanding the "go" function. There is a recursive call and it is calculating the LCM of all the divisors? Can someone explain the logic behind this function in simple terms? Is there a formula for this?

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English motatoes 2019-08-23 21:35:41 518 Initial revision (published)