#  find the GCD of two input numbers
gcd <- function(x, y) {
    gcd1 <- 1
    # choose the smaller number
    if(x > y) {
        smaller = y
    } else {
        smaller = x
    }
    for(i in 1:smaller) {
        if((x %% i == 0) && (y %% i == 0)) {
            gcd1 = i
        }
    }

    return(gcd1)
}

# the LCM involves a simple operation:
lcm <- function(x,y) {
    return((x * y)/gcd(x,y))
}

x = 10 
y = 24

print(paste("The L.C.M. of", x,"and", y,"is", lcm(x, y)))

