Skip to main content
added 284 characters in body
Source Link
aaaaaaaaaaaa
  • 4.4k
  • 1
  • 16
  • 24

#GolfScript 43#43 41#

~10\?1:b 461,{)b*:b@+\}460*;*b/`);(;'2.'\

Edit: I might as well replace the 0 with the leftover 1 from initializing b, the resulting difference is far too small to make it to the output.

I left the old version as that is what I have documented below.

~10\?1:b;0 461,{)b*:b@+\}460*;*b/`);(;'2.'\

~10\? Take input and calculate 10^input, leave the result on the stack.
1:b; Store 1 in b.
0 461, Put 0 on the stack, put the array [0 1 ... 459 460] on the stack.
{ }460* Execute function 460 times.
)b*:b Take the last element of the array, multiply it by b, store result in b and leave the result on the stack.
@+\ Switch the 0 (which is only a zero at the first iteration) to the top of the stack, add it to the leftover b value, and switch the result back again.
; Remove the rest of the array (only [0] is left).
The number that was initialized to 0 now hold the value e460! and b hold 460!
* Multiply 10^input by e
460! (they are at this point the only 2 elements left on the stack).
b/ Divide the result by b.
The stack now hold the value e*10^input which when converted to a string will hold all the decimals, but not the dot.
```);(;'2.'`` A bunch of string operations to fit in the dot.

e460! is calculated as 1 + 460 + 460459 + 460459458 etc.

#GolfScript 43#

~10\?1:b;0 461,{)b*:b@+\}460*;*b/`);(;'2.'\

~10\? Take input and calculate 10^input, leave the result on the stack.
1:b; Store 1 in b.
0 461, Put 0 on the stack, put the array [0 1 ... 459 460] on the stack.
{ }460* Execute function 460 times.
)b*:b Take the last element of the array, multiply it by b, store result in b and leave the result on the stack.
@+\ Switch the 0 (which is only a zero at the first iteration) to the top of the stack, add it to the leftover b value, and switch the result back again.
; Remove the rest of the array (only [0] is left).
The number that was initialized to 0 now hold the value e460! and b hold 460!
* Multiply 10^input by e
460! (they are at this point the only 2 elements left on the stack).
b/ Divide the result by b.
The stack now hold the value e*10^input which when converted to a string will hold all the decimals, but not the dot.
```);(;'2.'`` A bunch of string operations to fit in the dot.

e460! is calculated as 1 + 460 + 460459 + 460459458 etc.

#GolfScript 43 41#

~10\?1:b 461,{)b*:b@+\}460*;*b/`);(;'2.'\

Edit: I might as well replace the 0 with the leftover 1 from initializing b, the resulting difference is far too small to make it to the output.

I left the old version as that is what I have documented below.

~10\?1:b;0 461,{)b*:b@+\}460*;*b/`);(;'2.'\

~10\? Take input and calculate 10^input, leave the result on the stack.
1:b; Store 1 in b.
0 461, Put 0 on the stack, put the array [0 1 ... 459 460] on the stack.
{ }460* Execute function 460 times.
)b*:b Take the last element of the array, multiply it by b, store result in b and leave the result on the stack.
@+\ Switch the 0 (which is only a zero at the first iteration) to the top of the stack, add it to the leftover b value, and switch the result back again.
; Remove the rest of the array (only [0] is left).
The number that was initialized to 0 now hold the value e460! and b hold 460!
* Multiply 10^input by e
460! (they are at this point the only 2 elements left on the stack).
b/ Divide the result by b.
The stack now hold the value e*10^input which when converted to a string will hold all the decimals, but not the dot.
```);(;'2.'`` A bunch of string operations to fit in the dot.

e460! is calculated as 1 + 460 + 460459 + 460459458 etc.

added 64 characters in body
Source Link
aaaaaaaaaaaa
  • 4.4k
  • 1
  • 16
  • 24

#GolfScript 43#

~10\?1:b;0 461,{)b*:b@+\}460*;*b/`);(;'2.'\

~10\? Take input and calculate 10^input, leave the result on the stack.
1:b; Store 1 in b.
0 461, Put 0 on the stack, put the array [0 1 ... 459 460] on the stack.
{ }460* Execute function 460 times.
)b*:b Take the last element of the array, multiply it by b, store result in b and leave the result on the stack.
@+\ Switch the 0 (which is only a zero at the first iteration) to the top of the stack, add it to the leftover b value, and switch the result back again.
; Remove the rest of the array (only [0] is left).
The number that was initialized to 0 now hold the value e460! and b hold 460!
* Multiply 10^input by e
460! (they are at this point the only 2 elements left on the stack).
b/ Divide the result by b.
The stack now hold the value e*10^input which when converted to a string will hold all the decimals, but not the dot.
```);(;'2.'`` A bunch of string operations to fit in the dot.

 

e460! is calculated as 1 + 460 + 460459 + 460459458 etc.

#GolfScript 43#

~10\?1:b;0 461,{)b*:b@+\}460*;*b/`);(;'2.'\

~10\? Take input and calculate 10^input, leave the result on the stack.
1:b; Store 1 in b.
0 461, Put 0 on the stack, put the array [0 1 ... 459 460] on the stack.
{ }460* Execute function 460 times.
)b*:b Take the last element of the array, multiply it by b, store result in b and leave the result on the stack.
@+\ Switch the 0 (which is only a zero at the first iteration) to the top of the stack, add it to the leftover b value, and switch the result back again.
; Remove the rest of the array (only [0] is left).
The number that was initialized to 0 now hold the value e460! and b hold 460!
* Multiply 10^input by e
460! (they are at this point the only 2 elements left on the stack).
b/ Divide the result by b.
The stack now hold the value e*10^input which when converted to a string will hold all the decimals, but not the dot.

 

#GolfScript 43#

~10\?1:b;0 461,{)b*:b@+\}460*;*b/`);(;'2.'\

~10\? Take input and calculate 10^input, leave the result on the stack.
1:b; Store 1 in b.
0 461, Put 0 on the stack, put the array [0 1 ... 459 460] on the stack.
{ }460* Execute function 460 times.
)b*:b Take the last element of the array, multiply it by b, store result in b and leave the result on the stack.
@+\ Switch the 0 (which is only a zero at the first iteration) to the top of the stack, add it to the leftover b value, and switch the result back again.
; Remove the rest of the array (only [0] is left).
The number that was initialized to 0 now hold the value e460! and b hold 460!
* Multiply 10^input by e
460! (they are at this point the only 2 elements left on the stack).
b/ Divide the result by b.
The stack now hold the value e*10^input which when converted to a string will hold all the decimals, but not the dot.
```);(;'2.'`` A bunch of string operations to fit in the dot.

e460! is calculated as 1 + 460 + 460459 + 460459458 etc.

Source Link
aaaaaaaaaaaa
  • 4.4k
  • 1
  • 16
  • 24

#GolfScript 43#

~10\?1:b;0 461,{)b*:b@+\}460*;*b/`);(;'2.'\

~10\? Take input and calculate 10^input, leave the result on the stack.
1:b; Store 1 in b.
0 461, Put 0 on the stack, put the array [0 1 ... 459 460] on the stack.
{ }460* Execute function 460 times.
)b*:b Take the last element of the array, multiply it by b, store result in b and leave the result on the stack.
@+\ Switch the 0 (which is only a zero at the first iteration) to the top of the stack, add it to the leftover b value, and switch the result back again.
; Remove the rest of the array (only [0] is left).
The number that was initialized to 0 now hold the value e460! and b hold 460!
* Multiply 10^input by e
460! (they are at this point the only 2 elements left on the stack).
b/ Divide the result by b.
The stack now hold the value e*10^input which when converted to a string will hold all the decimals, but not the dot.