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.
You take two lists from the input and generate a new list of what they have in common. That is, for each p^n, if they share the p propagate p^(min n1 n2) to the result. If they don't share p, drop it (since then the min is p^0 = 1). Then take that new list and perform the same action with another list from the input, and so on.
An example using the first 3 lines. I've transposed the second and third as the steps are slightly more interesting, but it works out the same:
Lists and GCD
You are viewing a single comment's thread. Return to all comments →
You take two lists from the input and generate a new list of what they have in common. That is, for each p^n, if they share the p propagate p^(min n1 n2) to the result. If they don't share p, drop it (since then the min is p^0 = 1). Then take that new list and perform the same action with another list from the input, and so on.
An example using the first 3 lines. I've transposed the second and third as the steps are slightly more interesting, but it works out the same:
The first two lines results in:
Which, when combined with the third line, results in:
You can then continue merging each line into this result, and what's left at the end is the answer.