forked from root/public
Compare commits
2 Commits
master
...
1154-isthe
Author | SHA1 | Date |
---|---|---|
Hamza elkhatri | 7a8d282924 | 2 years ago |
hamza | 1133903ff6 | 2 years ago |
1 changed files with 48 additions and 0 deletions
@ -0,0 +1,48 @@ |
|||||||
|
## is-the-square-a-child |
||||||
|
|
||||||
|
### Instructions |
||||||
|
|
||||||
|
Write a function `IsTheSquareAChild` that takes a number and returns `true` if the number is a square and `false` otherwise. |
||||||
|
- The function should return `false` if the number is negative. |
||||||
|
- Check only if the first parameter is the square of the second one. |
||||||
|
|
||||||
|
### Expected Function |
||||||
|
```go |
||||||
|
func IsTheSquareAChild(number int, square int) bool { |
||||||
|
// your code here |
||||||
|
} |
||||||
|
``` |
||||||
|
|
||||||
|
### Usage |
||||||
|
|
||||||
|
Here is a possible program to test your function: |
||||||
|
|
||||||
|
``` go |
||||||
|
package main |
||||||
|
|
||||||
|
import "fmt" |
||||||
|
|
||||||
|
func main(){ |
||||||
|
fmt.Println(IsTheSquareAChild(4, 16)) |
||||||
|
fmt.Println(IsTheSquareAChild(5, 23)) |
||||||
|
fmt.Println(IsTheSquareAChild(5, 25)) |
||||||
|
fmt.Println(IsTheSquareAChild(2, 27)) |
||||||
|
fmt.Println(IsTheSquareAChild(6, 36)) |
||||||
|
fmt.Println(IsTheSquareAChild(-10, 100)) |
||||||
|
fmt.Println(IsTheSquareAChild(100,10)) |
||||||
|
} |
||||||
|
``` |
||||||
|
|
||||||
|
and its output: |
||||||
|
|
||||||
|
```console |
||||||
|
$ go run . |
||||||
|
true |
||||||
|
false |
||||||
|
true |
||||||
|
false |
||||||
|
true |
||||||
|
false |
||||||
|
false |
||||||
|
``` |
||||||
|
|
Loading…
Reference in new issue