Integer roots: Difference between revisions
m
→{{header|Python}}: (applied pylint to formatting)
SqrtNegInf (talk | contribs) m (→{{header|Perl 6}}: generate initial guess numerically) |
m (→{{header|Python}}: (applied pylint to formatting)) |
||
Line 660:
=={{header|Python}}==
<lang python>def root(a, b):
if b < 2:
c = 1
d=(a1*c+b//(c**a1))//a▼
while c not in
c, d, e = d, e, (a1 * e + b // (e ** a1)) // a
return min(d, e)
print("First 2,001 digits of the square root of two:\n{}".format(root(2,2*100**2000)))</lang>▼
root(2, 2 * 100 ** 2000)
))</lang>
{{out}}
|