You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
775 B

## Square-root
### Instructions
Write a function that takes a number and returns the square root of that number.
- The square root of a number is the number divided by two until the number is less than or equal to one.
2 years ago
- If the number is less than zero return `-1`.
### Expected function
2 years ago
```go
func SquareRoot(number int) int {
// Your code here
}
```
### Usage
2 years ago
Here is a possible program to test your function:
```go
package main
2 years ago
import (
"fmt"
2 years ago
)
func main() {
2 years ago
fmt.Println(SquareRoot(9))
fmt.Println(SquareRoot(16))
fmt.Println(SquareRoot(25))
fmt.Println(SquareRoot(26))
fmt.Println(SquareRoot(0))
fmt.Println(SquareRoot(-1))
fmt.Println(SquareRoot(1))
}
```
and the output should be:
```console
$ go run .
3
4
5
2 years ago
5
0
-1
2 years ago
1
2 years ago
```