PronicNumber returns true if argument passed to the function is pronic and false otherwise.
(n int)
| 15 | |
| 16 | // PronicNumber returns true if argument passed to the function is pronic and false otherwise. |
| 17 | func PronicNumber(n int) bool { |
| 18 | if n < 0 || n%2 == 1 { |
| 19 | return false |
| 20 | } |
| 21 | x := int(math.Sqrt(float64(n))) |
| 22 | return n == x*(x+1) |
| 23 | } |
no outgoing calls