SHARE
TWEET

Untitled

a guest Sep 17th, 2019 87 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. fun lcm(m: Int, n: Int): Int {
  2.     var m = m
  3.     var safetym = m
  4.     var safetyn = n
  5.     var k = m
  6.     var n = n
  7.     var i = 2
  8.     if ((m % n == 0) && (m > n)) return m
  9.     if ((n % m == 0) && (n > m)) return n
  10.     if (m > n) {
  11.      while ((k % m !=0) || (k % n != 0)) {
  12.          m = safetym
  13.          m *= i
  14.          k = m
  15.          i++
  16.      }
  17.     }
  18.     else {
  19.         while ((k % m != 0) || (k % n != 0)) {
  20.             n = safetyn
  21.             n *= i
  22.             k = n
  23.             i++
  24.         }
  25.     }
  26.     return k
  27. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top