I would suggest that you not use math.pow to square things. Just do i*i instead of math.pow(i, 2). I expect that you will find it is much faster to run in addition to being shorter to type. As a general rule, using math.pow is inefficient for any small integer power. In this case, it is particularly bad because i is an integer and math.pow is working with doubles and the conversion from Int to Double also has a cost.
I would suggest that you not use math.pow to square things. Just do
i*i
instead ofmath.pow(i, 2)
. I expect that you will find it is much faster to run in addition to being shorter to type. As a general rule, using math.pow is inefficient for any small integer power. In this case, it is particularly bad because i is an integer andmath.pow
is working with doubles and the conversion from Int to Double also has a cost.Done, thank you!