def sqr3(n):
... k = 1.0
... while((k*k - n) > 0.0000000001 or (n - k * k) > 0.0000000001):
... k = (k + n / k) / 2
... return k
say you want to find the square root of 2:
1)(1+2/1)/2=1.5;
2)(1.5+2/1.5)/2=1.4xyz,
3)(1.4xyz+2/1.4xyz)/2=1.4abc,
4).......
5)you will get 1.414..
No comments:
Post a Comment