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.
u have posed the doubt bit a time ago.
hope my clarification might help u
f is lcm of a, l is gcd of b.i is initialised to f and j is initialised to 2,
the termination condition is that i must not exceed l .inside the loop,we need to check if either i or its multiples divide l and their count.to get the next multiple of i,we use j.after the 1st iteration ,i is assigned the value of its next multiple by multiplying its current value with j and j is incremented and the loop goes on
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Between Two Sets
You are viewing a single comment's thread. Return to all comments →
u have posed the doubt bit a time ago. hope my clarification might help u
f is lcm of a, l is gcd of b.i is initialised to f and j is initialised to 2, the termination condition is that i must not exceed l .inside the loop,we need to check if either i or its multiples divide l and their count.to get the next multiple of i,we use j.after the 1st iteration ,i is assigned the value of its next multiple by multiplying its current value with j and j is incremented and the loop goes on