Greatest Common Divisor and Least Common Multiplier

Jan 11, 2021  ·  ~1min read
Notes #algorithm #go #math

Photo by @roman_lazygeek on Unsplash

I only rewrite what was written on my pastebin

package main

import "fmt"

func findGCD(a, b int) int {
  if b == 0 {
    return a
  }

  return findGCD(b, a%b)
}

func findLCM(a, b int) int {
  return a * b / findGCD(a, b)
}

func main() {
  fmt.Println(findGCD(25, 100))
  fmt.Println(findLCM(25, 100))
}
Thank you for reading!