From f3a1b74bd9b904c6b120bf6ff4e29b743e8aeec6 Mon Sep 17 00:00:00 2001 From: zainabdnaya Date: Mon, 20 Jun 2022 16:29:21 +0100 Subject: [PATCH] squareroot --- subjects/squareroot/README.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/subjects/squareroot/README.md b/subjects/squareroot/README.md index 246896fc..af8c4239 100644 --- a/subjects/squareroot/README.md +++ b/subjects/squareroot/README.md @@ -2,8 +2,8 @@ ### 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. +- If the number is less than zero return `-1`. ### Expected function ```go @@ -14,6 +14,8 @@ func SquareRoot(number int) int { ### Usage +Here is a possible program to test your function: + ```go package main @@ -25,6 +27,8 @@ func main() { fmt.Println(SquareRoot(25)) fmt.Println(SquareRoot(26)) fmt.Println(SquareRoot(0)) + fmt.Println(SquareRoot(-1)) + fmt.Println(SquareRoot(1)) } ``` @@ -35,6 +39,8 @@ $ go run . 3 4 5 +5 +0 -1 --1 +1 ``` \ No newline at end of file