DEV Community

loading...

Discussion on: Daily Challenge #281 - Area or Perimeter

Collapse
sergiuprt profile image
Sergiu Pruteanu

learning Go

func area_or_perimeter(x int, y int) int {
     if x == y {
        return x * y
    } else {
        return 2 * (x + y)
    }
}

func main() {
    //tests
    fmt.Println(area_or_perimeter(5, 5))
    fmt.Println(area_or_perimeter(10, 20))
}