Created
February 14, 2020 13:10
-
-
Save telliott99/79178d6752b6f7b9325476a64bc82953 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
s = int(sys.argv[1]) | |
def next(n): | |
n*= 10 | |
e = (len(str(n))-1) * 2 | |
t = s * 10**e | |
m = n | |
for i in range(10): | |
m += 1 | |
if m**2 > t: | |
break | |
return m - 1 | |
n = 1 | |
for i in range(25): | |
n = next(n) | |
print n | |
''' | |
> python sqrt2.py 2 | |
14142135623730950488016887 | |
> python sqrt2.py 3 | |
17320508075688772935274463 | |
> | |
''' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment