mirror of https://github.com/01-edu/public.git
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.
51 lines
896 B
51 lines
896 B
2 years ago
|
## is-square
|
||
2 years ago
|
|
||
|
### Instructions
|
||
|
|
||
2 years ago
|
Write a function `IsSquare` that takes two numbers and returns `true` if the second number is the square of the first and `false` otherwise.
|
||
2 years ago
|
- The function should return `false` if any of the parameters are negative
|
||
|
- Check only if the second parameter is the square of the first one.
|
||
2 years ago
|
|
||
|
### Expected Function
|
||
|
```go
|
||
2 years ago
|
func IsSquare(number int, square int) bool {
|
||
2 years ago
|
// your code here
|
||
|
}
|
||
|
```
|
||
|
|
||
|
### Usage
|
||
|
|
||
2 years ago
|
Here is a possible program to test your function:
|
||
|
|
||
2 years ago
|
``` go
|
||
|
package main
|
||
|
|
||
|
import "fmt"
|
||
|
|
||
|
func main(){
|
||
2 years ago
|
fmt.Println(IsSquare(4, 16))
|
||
|
fmt.Println(IsSquare(5, 23))
|
||
|
fmt.Println(IsSquare(5, 25))
|
||
|
fmt.Println(IsSquare(2, 27))
|
||
|
fmt.Println(IsSquare(6, 36))
|
||
|
fmt.Println(IsSquare(-10, 100))
|
||
|
fmt.Println(IsSquare(100,10))
|
||
|
fmt.Println(IsSquare(8, -64))
|
||
2 years ago
|
}
|
||
|
```
|
||
|
|
||
|
and its output:
|
||
|
|
||
|
```console
|
||
|
$ go run .
|
||
|
true
|
||
|
false
|
||
|
true
|
||
|
false
|
||
|
true
|
||
|
false
|
||
|
false
|
||
2 years ago
|
false
|
||
2 years ago
|
```
|
||
|
|