From 2cc3501e1785adda846296c913f9e5e05e32381d Mon Sep 17 00:00:00 2001 From: hamza Date: Fri, 17 Jun 2022 22:30:19 +0100 Subject: [PATCH] subject(square-root): add readmed --- subjects/squareroot/README.md | 40 +++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 subjects/squareroot/README.md diff --git a/subjects/squareroot/README.md b/subjects/squareroot/README.md new file mode 100644 index 00000000..246896fc --- /dev/null +++ b/subjects/squareroot/README.md @@ -0,0 +1,40 @@ +## Square-root + +### Instructions +Write a function that takes a number and returns the square root of that number. +- If the number is less than one or the number does not have an integer square root, return `-1`. +- The square root of a number is the number divided by two until the number is less than or equal to one. + +### Expected function +```go +func SquareRoot(number int) int { + // Your code here +} +``` + +### Usage + +```go +package main + +import "fmt" + +func main() { + fmt.Println(SquareRoot(9)) + fmt.Println(SquareRoot(16)) + fmt.Println(SquareRoot(25)) + fmt.Println(SquareRoot(26)) + fmt.Println(SquareRoot(0)) +} +``` + +and the output should be: + +```console +$ go run . +3 +4 +5 +-1 +-1 +``` \ No newline at end of file