DEV Community

Clavin June
Clavin June

Posted on • Originally published at clavinjune.dev on

Greatest Common Divisor and Least Common Multiplier

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))
}
Enter fullscreen mode Exit fullscreen mode

Thank you for reading!

Top comments (0)