I am trying to get a slice of big.Ints
of the odd numbers between 3 and the square root of i
.
When I run the following code:
import (
"fmt"
"math/big"
)
func main() {
i := big.NewInt(101)
var divisorsOfPrime []*big.Int
squareRoot := big.NewInt(0).Sqrt(i)
for n := big.NewInt(3); n.Cmp(squareRoot) == -1; n.Add(n, big.NewInt(2)) {
divisorsOfPrime = append(divisorsOfPrime, n)
}
fmt.Println(divisorsOfPrime)
}
I get the output:
[11 11 11 11]
But I expect the output:
[3 5 7 9 11]
What can I do to fix this?
Thanks