Min(x, y int)
and Max(x, y int)
functions that take two integers and return the lesser or greater value, respectively.package main
import "fmt"
// Min returns the smaller of x or y.
func Min(x, y int) int {
if x > y {
return y
}
return x
}
// Max returns the larger of x or y.
func Max(x, y int) int {
if x < y {
return y
}
return x
}
func main() {
fmt.Println(Min(5,10))
fmt.Println(Max(5,10))
}​
Output :
5
10