We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.

Your lcm and gcd functions looks fine. But the way you calculated the lcm or gcd for the whole array is not correct. In your current implementation you will get the lcm or gcd only for the last two elements of the array. Try to find how to calculate those for the whole array.

For step-3, if f evenly divides g, then count the number of multiples of f which evenly divides g.
Evenly divides means if g is divided by f then the remainder will be 0.

g%f==0

and multiple of f means f,2*f,3*f,4*f... so on.
In your case you you have to count the number of multiple of f which evenly divides g. like

## Between Two Sets

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

Your lcm and gcd functions looks fine. But the way you calculated the lcm or gcd for the whole array is not correct. In your current implementation you will get the lcm or gcd only for the last two elements of the array. Try to find how to calculate those for the whole array.

For step-3, if

fevenly dividesg, then count the number of multiples offwhich evenly dividesg. Evenly divides means ifgis divided byfthen the remainder will be 0.and multiple of f means f,2*f,3*f,4*f... so on. In your case you you have to count the number of multiple of

fwhich evenly dividesg. like