Skip to content

Instantly share code, notes, and snippets.

@AndreUltrasi
Created November 27, 2016 01:39
Show Gist options
  • Save AndreUltrasi/52d25f532a0a2c0d45db9e321ad1903e to your computer and use it in GitHub Desktop.
Save AndreUltrasi/52d25f532a0a2c0d45db9e321ad1903e to your computer and use it in GitHub Desktop.
Serie (11)*n-(2)*n=((3)*n)**2 em python
"""11-2=3**2
1111-22=33**2
111111-222=333**2"""
n = 1
while n != 18 :
tmp = n
x = 0
y = 0
while tmp > 0:
x += 10**(tmp-1)*(10**(tmp-1) + 10**(tmp))
tmp -= 1
tmp = n
while tmp > 0:
y += 2*10**(tmp-1)
tmp -= 1
z = int((x - y)**0.5)
print ("n =",n)
print("{} - {} = {}**2".format(x,y,z))
n += 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment