Table Of Contents

LCM (G Dataflow)

Version:
    Last Modified: January 9, 2017

    Computes the least common multiple of the input values.

    connector_pane_image
    datatype_icon

    x

    An integer.

    datatype_icon

    y

    An integer.

    datatype_icon

    error in

    Error conditions that occur before this node runs. The node responds to this input according to standard error behavior.

    Default: No error

    datatype_icon

    LCM(x, y)

    Least common multiple of x and y.

    datatype_icon

    error out

    Error information. The node produces this output according to standard error behavior.

    Algorithm for Computing the Least Common Multiple

    LCM(x,y) is the smallest integer m for which there exist integers c and d such that

    x × c = y × d = m

    To compute LCM(x,y), consider the prime factorizations of x and y:

    x = i p i a i
    y = i p i b i

    where pi are all the prime factors of x and y. If pi does not occur in a factorization, the corresponding exponent is 0. LCM(x,y) then is given by:

    LCM ( x , y ) = i p i max ( a i , b i )

    The prime factorizations of 12 and 30 are given by:

    12 = 2 2 × 3 1 × 5 0
    30 = 2 1 × 3 1 × 5 1

    so

    LCM ( 12 , 30 ) = 2 2 × 3 1 × 5 1 = 60

    Where This Node Can Run:

    Desktop OS: Windows

    FPGA: Not supported


    Recently Viewed Topics