MCPcopy Create free account
hub / github.com/TheAlgorithms/Go / PronicNumber

Function PronicNumber

math/pronicnumber.go:17–23  ·  view source on GitHub ↗

PronicNumber returns true if argument passed to the function is pronic and false otherwise.

(n int)

Source from the content-addressed store, hash-verified

15
16// PronicNumber returns true if argument passed to the function is pronic and false otherwise.
17func 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}

Callers 2

TestPronicNumberFunction · 0.92
BenchmarkPronicNumberFunction · 0.92

Calls

no outgoing calls

Tested by 2

TestPronicNumberFunction · 0.74
BenchmarkPronicNumberFunction · 0.74