• + 0 comments

    Some hint:

    Suppose the input is [A,B,C,,...]

    The first value of the list should be one number X such that : A = gcd(X,??) In other words: X should be multiple of A.

    Because the sum have to be minimal, lets try the lowest multiple of A (X = A).

    From here, whats the second number Y of the list? We have two restrictions of Y: A = gcd(X,Y) B = gcd(Y, ??) In other words Y should be a multiple of A and a multiple of B. Again, because the sum have to be minimal, get the lowest multiple of A and B ( Least Common Multiple)

    Iterate from there...