Experience our interactive coding environment with this simple Go challenge. See how our platform helps you learn and practice Go programming.
This is a simplified version of our actual challenge interface. Fork the repository to access all 30+ challenges with full testing, submissions, and leaderboards!
Write a function Sum
that takes two integers and returns their sum.
func Sum(a int, b int) int
2, 3
5
-5, 10
5
-10^9 <= a, b <= 10^9
Click "Show Next Hint" to reveal hints one by one
Functions in Go are declared using the func
keyword followed by the function name, parameters, and return type.
func functionName(param1 type1, param2 type2) returnType {
// function body
return value
}
Go functions can have zero or more parameters. If consecutive parameters have the same type, you can omit the type from all but the last:
func add(a, b int) int {
return a + b
}
Functions can return multiple values. This challenge requires returning a single integer.
Go's syntax is designed to be simple and readable. The sum function you're implementing is one of the most basic operations in programming!
This was just a taste! Get access to all 30+ challenges with automated testing, submissions, leaderboards, AI interview simulation, and much more.