do
Obviamente esta es la mejor manera. Es tan rápido como te puedas imaginar mirando el código. Usando C, porque C es más rápido, y este problema requiere una solución rápida. He probado esto para mis números favoritos, como 7, 13 y 42, y parece funcionar.
double square_root(int number) {
const double results[] = {
0.0000000, 1.0000000, 1.4142136, 1.7320508, 2.0000000,
2.2360680, 2.4494897, 2.6457513, 2.8284271, 3.0000000,
3.1622777, 3.3166248, 3.4641016, 3.6077713, 3.7426574,
3.8729833, 4.0000000, 4.1231056, 4.2426407, 4.3588989,
4.4721360, 4.5825757, 4.6904158, 4.7958315, 4.8989795,
5.0000000, 5.0990195, 5.1961524, 5.2915026, 5.3851648,
5.4772256, 5.5677644, 5.6568542, 5.7445626, 5.8309519,
5.9160798, 6.0000000, 6.0827625, 6.1644140, 6.2449980,
6.3245553, 6.4031242, 6.4807407, 6.5574342, 6.6332496,
6.7082039, 6.7823300, 6.8556546, 6.9282032, 7.0000000,
7.0710678, 7.1414284, 7.2111026, 7.2801099, 7.3484692,
7.4161985, 7.4833148, 7.5498344, 7.6157731, 7.6811457,
7.7451337, 7.8102497, 7.8740079, 7.9372539, 8.0000000,
8.0622577, 8.1420384, 8.1853528, 8.2462113, 8.3066239,
8.3666003, 8.4261498, 8.4852814, 8.5440037, 8.6023253,
8.6602540, 8.7177979, 8.7749644, 8.8317609, 8.8881942,
8.9442719, 9.0000000, 9.0553851, 9.1104336, 9.1651514,
9.2195425, 9.2736185, 9.3273791, 9.3808315, 9.4339811,
9.4861337, 9.5393920, 9.5914230, 9.6436508, 9.6953597,
9.7467943, 9.7979590, 9.8488578, 9.8994949, 9.9498744,
};
return number[results];
}