Least common multiple P62143


Statement
 

pdf   zip

Least common multiple

Your task is to write a program such that, given nn strictly positive natural numbers x1,,xnx_1,\dots,x_n, prints their least common multiple greater than zero.

Input

The input consists of zero or more cases. Each case consists of two lines: the first one with a natural n1n\ge 1; the second one with x1,,xnx_1,\dots,x_n. A special line with n=0n = 0 indicates the end of the input.

Output

For each case of the input, your program must print in a line the least strictly positive common multiple of x1,,xnx_1,\dots,x_n.

Observation

Use the function |gcd()| of the exercise MCD3 .

Author

Salvador Roura (en: Carlos Molina)

© Jutge.org, 2006–2025.

Public test cases
  • Input

    3
    14 4 5
    1
    7
    0
    

    Output

    140
    7
    
  • Information
    Author
    Salvador Roura
    Language
    English
    Translator
    Carlos Molina
    Original language
    Catalan
    Other languages
    Catalan
    Official solutions
    C++
    User solutions
    C++