Skip to main content
5 of 7
added 242 characters in body
Shieru Asakoto
  • 6.3k
  • 16
  • 40

Python 2, 193 180 179 bytes

d=10
u=d**2000
v=u*u
def s(n,a=d,i=9):
 while a!=i:i,a=a,(a+n/a)/2
 return a
p,q,r,t=s(2*v),s(3*v),1,0
while p:t+=(p+q)%d*r;p/=d;q/=d;r*=d
for i in range(1000):print t/u;t=v/(t%u)

Try it online!

Calculating sqrt(2) and sqrt(3) to such a precision with a short code is a tough job in Python and other languages.

2000 digits is needed to ensure the expansion is correct, and lines 4-6 is the integer square root.

193 > 180 : The digit-wise modulo sum is now carried by a loop instead of array manipulation

180 > 179 : Replaced the 6 occurrences of 10 using d with the cost of defining with 5 bytes, cutting 1 byte in total

Shieru Asakoto
  • 6.3k
  • 16
  • 40