github.com/ncruces/go-sqlite3@v0.15.1-0.20240520133447-53eef1510ff0/vfs/adiantum/math.go (about) 1 package adiantum 2 3 func abs(n int) int { 4 if n < 0 { 5 return -n 6 } 7 return n 8 } 9 10 func gcd(m, n int) int { 11 for n != 0 { 12 m, n = n, m%n 13 } 14 return abs(m) 15 } 16 17 func lcm(m, n int) int { 18 if n == 0 { 19 return 0 20 } 21 return abs(n) * (abs(m) / gcd(m, n)) 22 }