Skip to main content
Commonmark migration
Source Link

#dc, 99 bytes

dc, 99 bytes

#dc, 99 bytes

dc, 99 bytes

added 117 characters in body
Source Link
Digital Trauma
  • 73k
  • 9
  • 112
  • 264

WhitespaceGolfed:

2?dsi1+^k1dddsa2v/sb4/stsp[lalb*vlalb+2/dla-d*lp*ltr-stsasblp2*spli1-dsi0<m]dsmxK2/1-klalb+d*4lt*/p

With whitespace and comments added for "readability":

Whitespace and comments added for "readability":

Golfed:

2?dsi1+^k1dddsa2v/sb4/stsp[lalb*vlalb+2/dla-d*lp*ltr-stsasblp2*spli1-dsi0<m]dsmxK2/1-klalb+d*4lt*/p

With whitespace and comments for "readability":

added 855 characters in body
Source Link
Digital Trauma
  • 73k
  • 9
  • 112
  • 264

#dc, 10199 bytes

Whitespace and comments added for "readability":

2?dsi               # Push 2. push input n, duplicate and store in i
1+^k                # Set calculation precision to 2^(n+1)
1dddsa              # Push four 1s. Store 1st in a
2v/sb               # Store 1/sqrt(2) in b
4/st                # Store 1/4 in t
sp                  # Store 1 in p
[                   # Start iteration loop macro
lalb*v              # Save sqrt(a*b) on stack
lalb+2/d            # Save a[i+1] = (a[i]+b[i])/2 on stack and duplicate
la-d*lp*ltr-        # Save t-p(a[i]-a[i+1])^2 on the stack
st                  # Store t result from stack
sa                  # Store a result from stack
sb                  # Store b result from stack
lp2*sp              # Store 2p in p
li1-dsi0<m]dsmxdsi0<m]         # Decrement iteration counter i; recurse into macro if < 0
dsmx                # Duplicate, store and run macro
K2/1-k              # Set display precision to 2^n-1
lalb+d*4lt*/        # Save (a+b)^2/4t on stack
nAPp                   # Print result

#dc, 101 bytes

Whitespace added for "readability":

2?dsi
1+^k
1dddsa
2v/sb
4/st
sp
[
lalb*v
lalb+2/d
la-d*lp*ltr-
st
sa
sb
lp2*sp
li1-dsi0<m]dsmx
K2/1-k
lalb+d*4lt*/
nAP

#dc, 99 bytes

Whitespace and comments added for "readability":

2?dsi               # Push 2. push input n, duplicate and store in i
1+^k                # Set calculation precision to 2^(n+1)
1dddsa              # Push four 1s. Store 1st in a
2v/sb               # Store 1/sqrt(2) in b
4/st                # Store 1/4 in t
sp                  # Store 1 in p
[                   # Start iteration loop macro
lalb*v              # Save sqrt(a*b) on stack
lalb+2/d            # Save a[i+1] = (a[i]+b[i])/2 on stack and duplicate
la-d*lp*ltr-        # Save t-p(a[i]-a[i+1])^2 on the stack
st                  # Store t result from stack
sa                  # Store a result from stack
sb                  # Store b result from stack
lp2*sp              # Store 2p in p
li1-dsi0<m]         # Decrement iteration counter i; recurse into macro if < 0
dsmx                # Duplicate, store and run macro
K2/1-k              # Set display precision to 2^n-1
lalb+d*4lt*/        # Save (a+b)^2/4t on stack
p                   # Print result
added 429 characters in body
Source Link
Digital Trauma
  • 73k
  • 9
  • 112
  • 264
Loading
added 233 characters in body
Source Link
Digital Trauma
  • 73k
  • 9
  • 112
  • 264
Loading
added 149 characters in body
Source Link
Digital Trauma
  • 73k
  • 9
  • 112
  • 264
Loading
deleted 1079 characters in body
Source Link
Digital Trauma
  • 73k
  • 9
  • 112
  • 264
Loading
Source Link
Digital Trauma
  • 73k
  • 9
  • 112
  • 264
Loading