What's the best way to take the square root of an int?

359 views Asked by At

I ended up writing this recently to get around a problem that math.sqrt deals in floats:

for i := 2; i < int(math.Ceil(math.Sqrt(float64(n)))); {

I had to look away from the editor while doing it, but it worked. If a wandering helpful Gopher happens across this, what should I do instead?

(Context: was doing a quick prime factoring algorithm for a project euler problem.)

0

There are 0 answers