1. Why is faster to compute i*i, sqrt (n) times. than sqrt (n) just one time?查看下面的复杂性。计算平方根的额外费用。
2. Why Math.sqrt() is faster than my sqrt() method ?
Math.sqrt()委托对StrictMath.sqrt的调用以硬件或本机代码完成。
3. What is the complexity of these algorithms?
您描述的每个功能的复杂性
i=2 .. i*i<nO(平方(n))
i=2 .. sqrt(n)O(sqrt(n)* log(n))
i=2 .. sqrt (by Newton's method)O(sqrt(n))+ O(log(n))
i=2 .. sqrt (by Math.sqrt)O(平方(n))
牛顿方法的复杂性,来自
http://en.citizendium.org/wiki/Newton%27s_method#Computational_complexity



