Advertisement
imk0tter

LCM

Jan 7th, 2020
732
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
mIRC 0.55 KB | None | 0 0
  1. alias gcd {
  2.   var %a $1, %b $2
  3.  
  4.   while (%b != 0) {
  5.     var %t %b
  6.     %b = $calc(%a % %b)
  7.     %a = %t
  8.   }
  9.  
  10.   return %a
  11. }
  12.  
  13. alias _lcm {
  14.   return $calc($1 * $2 / $gcd($1, $2))
  15. }
  16.  
  17. alias LCM {
  18.   tokenize 32 $1-
  19.   if $0 >= 2 {
  20.     return $LCMA($_lcm($1,$2) $3-)
  21.   }
  22.   else {
  23.     return $1
  24.   }
  25. }
  26.  
  27. alias LCMA {
  28.   tokenize 32 $1-
  29.   if $0 >= 2 {
  30.     return $LCMB($_lcm($1,$2) $3-)
  31.   }
  32.   else {
  33.     return $1
  34.   }
  35. }
  36.  
  37. alias LCMB {
  38.   tokenize 32 $1-
  39.   if $0 >= 2 {
  40.     return $LCMA($_lcm($1,$2) $3-)
  41.   }
  42.   else {
  43.     return $1
  44.   }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement