Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
3 replaced http://codegolf.stackexchange.com/ with https://codegolf.stackexchange.com/
source | link

Japt, 45 bytes

Japt is a shortened version of JavaScript. InterpreterInterpreter

$for(V=X=1;X<1e9;)$V*=(1+1/X pU /(1+U/X++;V/U

Of course, 1e9 = 1,000,000,000 iterations takes forever, so for testing, try replacing the 9 with a 6. (1e6 is accurate to ~5 significant figures. Using 1e8 on an input of 12 is enough to get the first six.)

Test-case results: (using 1e7 precision)

       1:  1
    -2.5: -0.9453083...
      pi:  2.2880370...
      -e: -0.9526812...
      12:  39916536.5...
     0.5:  1.7724538...
8.675309:  20248.319...
   -10.1: -0.0000022...

How it works

         // Implicit: U = input number
$for(    // Ordinary for loop.
V=X=1;   //  Set V and X to 1.
X<1e9;)$ //  Repeat while X is less than 1e9.
V*=      // Multiply V by:
(1+1/X   //  1 plus (1 over X),
pU /     //  to the power of U, divided by
(1+U/X++ //  1 plus (U over X). Increment X by 1.
;V/U     // Output the result of (V over U).

Japt, 45 bytes

Japt is a shortened version of JavaScript. Interpreter

$for(V=X=1;X<1e9;)$V*=(1+1/X pU /(1+U/X++;V/U

Of course, 1e9 = 1,000,000,000 iterations takes forever, so for testing, try replacing the 9 with a 6. (1e6 is accurate to ~5 significant figures. Using 1e8 on an input of 12 is enough to get the first six.)

Test-case results: (using 1e7 precision)

       1:  1
    -2.5: -0.9453083...
      pi:  2.2880370...
      -e: -0.9526812...
      12:  39916536.5...
     0.5:  1.7724538...
8.675309:  20248.319...
   -10.1: -0.0000022...

How it works

         // Implicit: U = input number
$for(    // Ordinary for loop.
V=X=1;   //  Set V and X to 1.
X<1e9;)$ //  Repeat while X is less than 1e9.
V*=      // Multiply V by:
(1+1/X   //  1 plus (1 over X),
pU /     //  to the power of U, divided by
(1+U/X++ //  1 plus (U over X). Increment X by 1.
;V/U     // Output the result of (V over U).

Japt, 45 bytes

Japt is a shortened version of JavaScript. Interpreter

$for(V=X=1;X<1e9;)$V*=(1+1/X pU /(1+U/X++;V/U

Of course, 1e9 = 1,000,000,000 iterations takes forever, so for testing, try replacing the 9 with a 6. (1e6 is accurate to ~5 significant figures. Using 1e8 on an input of 12 is enough to get the first six.)

Test-case results: (using 1e7 precision)

       1:  1
    -2.5: -0.9453083...
      pi:  2.2880370...
      -e: -0.9526812...
      12:  39916536.5...
     0.5:  1.7724538...
8.675309:  20248.319...
   -10.1: -0.0000022...

How it works

         // Implicit: U = input number
$for(    // Ordinary for loop.
V=X=1;   //  Set V and X to 1.
X<1e9;)$ //  Repeat while X is less than 1e9.
V*=      // Multiply V by:
(1+1/X   //  1 plus (1 over X),
pU /     //  to the power of U, divided by
(1+U/X++ //  1 plus (U over X). Increment X by 1.
;V/U     // Output the result of (V over U).
2 added 270 characters in body
source | link

Japt, 45 bytes

Japt is a shortened version of JavaScript. Interpreter

$for(V=X=1;X<1e9;)$V*=(1+1/X pU /(1+U/X++;V/U

Of course, 1e9 = 1,000,000,000 iterations takes forever, so for testing, try replacing the 9 with a 6. (1e6 is accurate to ~5 significant figures. Using 1e8 on an input of 12 is enough to get the first six.)

Test-case results: (using 1e7 precision)

       1:  1
    -2.5: -0.9453083...
      pi:  2.2880370...
      -e: -0.9526812...
      12:  39916536.5...
     0.5:  1.7724538...
8.675309:  20248.319...
   -10.1: -0.0000022...

How it works

         // Implicit: U = input number
$for(    // Ordinary for loop.
V=X=1;   //  Set V and X to 1.
X<1e9;)$ //  Repeat while X is less than 1e9.
V*=      // Multiply V by:
(1+1/X   //  1 plus (1 over X),
pU /     //  to the power of U, divided by
(1+U/X++ //  1 plus (U over X). Increment X by 1.
;V/U     // Output the result of (V over U).

Japt, 45 bytes

Japt is a shortened version of JavaScript. Interpreter

$for(V=X=1;X<1e9;)$V*=(1+1/X pU /(1+U/X++;V/U

Of course, 1e9 = 1,000,000,000 iterations takes forever, so for testing, try replacing the 9 with a 6. (1e6 is accurate to ~5 significant figures. Using 1e8 on an input of 12 is enough to get the first six.)

How it works

         // Implicit: U = input number
$for(    // Ordinary for loop.
V=X=1;   //  Set V and X to 1.
X<1e9;)$ //  Repeat while X is less than 1e9.
V*=      // Multiply V by:
(1+1/X   //  1 plus (1 over X),
pU /     //  to the power of U, divided by
(1+U/X++ //  1 plus (U over X). Increment X by 1.
;V/U     // Output the result of (V over U).

Japt, 45 bytes

Japt is a shortened version of JavaScript. Interpreter

$for(V=X=1;X<1e9;)$V*=(1+1/X pU /(1+U/X++;V/U

Of course, 1e9 = 1,000,000,000 iterations takes forever, so for testing, try replacing the 9 with a 6. (1e6 is accurate to ~5 significant figures. Using 1e8 on an input of 12 is enough to get the first six.)

Test-case results: (using 1e7 precision)

       1:  1
    -2.5: -0.9453083...
      pi:  2.2880370...
      -e: -0.9526812...
      12:  39916536.5...
     0.5:  1.7724538...
8.675309:  20248.319...
   -10.1: -0.0000022...

How it works

         // Implicit: U = input number
$for(    // Ordinary for loop.
V=X=1;   //  Set V and X to 1.
X<1e9;)$ //  Repeat while X is less than 1e9.
V*=      // Multiply V by:
(1+1/X   //  1 plus (1 over X),
pU /     //  to the power of U, divided by
(1+U/X++ //  1 plus (U over X). Increment X by 1.
;V/U     // Output the result of (V over U).
1
source | link

Japt, 45 bytes

Japt is a shortened version of JavaScript. Interpreter

$for(V=X=1;X<1e9;)$V*=(1+1/X pU /(1+U/X++;V/U

Of course, 1e9 = 1,000,000,000 iterations takes forever, so for testing, try replacing the 9 with a 6. (1e6 is accurate to ~5 significant figures. Using 1e8 on an input of 12 is enough to get the first six.)

How it works

         // Implicit: U = input number
$for(    // Ordinary for loop.
V=X=1;   //  Set V and X to 1.
X<1e9;)$ //  Repeat while X is less than 1e9.
V*=      // Multiply V by:
(1+1/X   //  1 plus (1 over X),
pU /     //  to the power of U, divided by
(1+U/X++ //  1 plus (U over X). Increment X by 1.
;V/U     // Output the result of (V over U).