lcm

lcm(x,y)

Least common (non-negative) multiple.

Examples

jldoctest
julia> lcm(4, 6)
12

julia> lcm(15, 20)
60

julia> lcm(7, 11)
77

The lcm function calculates the least common multiple of two integers x and y. It returns the smallest positive integer that is divisible by both x and y.

Here are some common examples of using the lcm function:

  1. Calculate the LCM of two numbers:

    julia> lcm(4, 6)
    12

    This example calculates the LCM of 4 and 6, which is 12.

  2. Find the LCM of two different numbers:

    julia> lcm(15, 20)
    60

    It calculates the LCM of 15 and 20, resulting in 60.

  3. Compute the LCM of prime numbers:
    julia> lcm(7, 11)
    77

    In this example, the LCM of 7 and 11 is calculated, resulting in 77.

Note: The lcm function works with both positive and negative integers.

See Also

User Contributed Notes

Add a Note

The format of note supported is markdown, use triple backtick to start and end a code block.

*Required Field
Details

Checking you are not a robot: