Skip to content

Instantly share code, notes, and snippets.

@telliott99
Created February 14, 2020 13:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save telliott99/79178d6752b6f7b9325476a64bc82953 to your computer and use it in GitHub Desktop.
Save telliott99/79178d6752b6f7b9325476a64bc82953 to your computer and use it in GitHub Desktop.
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