[Question]
  [
## Task
Given an integer, `n`, where `3 <= n < 2^32`, calculate the area of a regular `n`-gon, with an apothem of 1, using the formula `A = n * tan(π / n)`.
> 
> [The apothem of a regular polygon is a line segment from the center to the midpoint of one of its sides.](https://en.wikipedia.org/wiki/Apothem)
> 
> 
> 
Output the area of this regular polygon as a floating point value showing no fewer than eight decimal places (i.e. `1.24217000`, `3.14159265`).
## Tests
```
In: 3
Out: 5.1961524227
In: 6
Out: 3.4641016151
In: 10
Out: 3.2491969623
In: 20
Out: 3.1676888065
In: 99
Out: 3.1426476062
In: 1697
Out: 3.1415962425
In: 15000
Out: 3.1415926995
```
Note: The output values in the sample cases above each show ten decimal places -- two more than required.
  
[Answer]
# Mathematica, 16 bytes
```
N[Tan[Pi/#]#,9]&
```
[Try it online!](https://tio.run/##y00sychMLv6fZvvfLzokMS86IFNfOVZZxzJW7X9AUWZeiYJDWrShqYGBQez//wA "Mathics – Try It Online")
of course mathematica has built-ins for this
```
Area@*RegularPolygon
```
[Answer]
# [Java (OpenJDK 9)](http://openjdk.java.net/projects/jdk9/), 24 bytes
```
i->i*Math.tan(Math.PI/i)
```
[Try it online!](https://tio.run/##ZY5BS8NAEIXP3V@xFAK7JR2rolBiexKhh4qQX7Amm2ZiMlmyk9RS@tvjWtOTpzfzPd7Mq8xglq2zVOVf6xEb13YsqwChZ6xhkYh/rOgpY2zp1xSu/6wxk1ltvJd7g3S@Ic@Ggwwt5rIJhkq5QzoAgOkOXp/F23Tn5bUNCRv/yVYWmxGXW1zsDZfAhtR1@NjdoR4TkWaGyHbSy40ke5TTrtKTZ9sAkk7EscTaKg@l8e/2m3fESoeHMySWQ8h5oBtOxGxKtj2DCw25UPMojyiCdRHRPB7iAoxz9Ump/NpQDzrELuJyGR/Fk3gW9yvxsPoB "Java (OpenJDK 9) – Try It Online")
[Answer]
# [Actually](https://github.com/Mego/Seriously), 5 bytes
```
╦/Tß*
```
[Try it online!](https://tio.run/##S0wuKU3Myan8///R1GX6IYfna/3/bwwA "Actually – Try It Online")
---
# How?
```
╦/Tß*   Full program.
╦       Push Pi.
 /      Divide ^ by the input.
  T     Tangent.
   ß*   Multiply by the input.
        Output implicitly.
```
Alternative: `ß╦/T*`. o\_O Actually actually beats [Jelly](https://codegolf.stackexchange.com/a/141528/59487)!!!
[Answer]
# x87 Machine Code, 11 bytes
```
D9 EB
DA 31
D9 F2
DD D8
DA 09
C3
```
The above bytes of code define a function that calculates the area of a regular n-gon with an apothem of 1. It uses [x87 FPU instructions](https://en.wikipedia.org/wiki/X87) (the classic floating-point unit on the x86 processors) to do this computation.
Following a standard x86 register-based calling convention (in this case, [`__fastcall`](https://en.wikipedia.org/wiki/X86_calling_conventions#Microsoft_fastcall)), the function's argument is a pointer to the integer, passed in the `ECX` register. The function's result is a floating-point value, returned at the top of the x87 floating-point stack (register `ST0`).
**[Try it online!](https://tio.run/##nY7vaoMwFMU/m6e4ODoS0WKVuYpbYWvXl1iGpPFPAzaOGIcw9upzV9wL6IdwOTfnd8@RQS3lOMpWdxbkVRgY9smxLcr3D3gGlw@nlA9vrzhf@BDvZn2OcJ7w7ed9iLtj7Gaks8IqCUXbX5oS8lxYa9Slt2WeU1qJzkrRNIwB9TDlPGhGlbYew6T/1Gy8U1o2fVHCU2cL1W6vB4IeuAmlJzMIU0t/bup5KL4Y@SbO9KPxTJwR59Ogqqi7KbgNDtxutruw4tr1Qfsw59J7zRhaJyRZjuzC5Uy0gknTFd2S9HEF9RCGCwsSx5S2NxqQ@xl/ZdWIuhuDWxz9AQ)**
**Ungolfed assembly mnemonics:**
```
D9 EB  fldpi                  ; load constant PI at top of FPU stack
DA 31  fidiv DWORD PTR [ecx]  ; divide PI by integer input (loaded from pointer
                              ;   in ECX), leaving result at top of FPU stack
D9 F2  fptan                  ; compute tangent of value at top of FPU stack
DD D8  fstp  st0              ; pop junk value (FPTAN pushes 1.0 onto stack)
DA 09  fimul DWORD PTR [ecx]  ; multiply by integer input (again, loaded via ECX)
C3     ret                    ; return control to caller
```
As you can see, this is basically just a straightforward computation of the given formula,  
     *result = n \* tan(π / n)*  
Only a couple of interesting things bear pointing out:
* The x87 FPU has a dedicated instruction for loading the constant value PI ([`FLDPI`](http://www.felixcloutier.com/x86/FLD1:FLDL2T:FLDL2E:FLDPI:FLDLG2:FLDLN2:FLDZ.html)). This was rarely used, even back in the day (and obviously much less so now), but it's shorter in size than embedding a constant into your binary and loading that.
* The x87 FPU instruction to calculate tangent, [`FPTAN`](http://www.felixcloutier.com/x86/FPTAN.html), replaces the value of the input register (the top of the FPU stack) with the result, but *also* pushes a constant 1.0 onto the top of the FPU stack. This is done for backwards compatibility with the 8087 (I have no idea why this was done on the 8087; probably a bug). That means we need to pop this unneeded value off of the stack. The fastest and shortest way to do that is a simple [`FSTP st0`](http://www.felixcloutier.com/x86/FST:FSTP.html), like we use here. We could have also done a [multiply-and-pop](http://x86.renejeschke.de/html/file_module_x86_id_104.html), since multiplying by 1.0 won't change the result, but this is also 2 bytes (so no win in code size), will probably execute more slowly, and may introduce unnecessary indeterminacy into the result.
Although a modern programmer or compiler would use the SSE (and later) instruction set, rather than the aging x87, this would require more code to implement, as there's no single instruction to compute a tangent in these newer ISAs.
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 6 bytes
```
ØP÷ÆT×
```
[Try it online!](https://tio.run/##y0rNyan8///wjIDD2w@3hRye/v//f0NTAwMDAA "Jelly – Try It Online")
Jelly's π builtin has >8 decimal places.
[Answer]
# [Brachylog](https://github.com/JCumin/Brachylog), 9 bytes
```
;π/₍*₄;?×
```
[Try it online!](https://tio.run/##SypKTM6ozMlPN/r/3/p8g/6jpl6tR00t1vaHp///b2hqYGDwPwoA "Brachylog – Try It Online")
[Answer]
## [Sakura](https://github.com/tuxcrafting/sakura), 4 bytes
```
*ĳ/π
```
This is expanded to `*ĳ/π⓪⓪`, which is
```
*              *
 ĳ     tan(   )
  /         /
   π       π
    ⓪        n
     ⓪          n
```
[Answer]
# [R](https://www.r-project.org/), 25 bytes
```
cat((n=scan())*tan(pi/n))
```
Input from stdin, output to stdout.
[Try it online!](https://tio.run/##K/qfX1CSmZ9XrJGSmZ5ZUmxrZKT5PzmxREMjz7Y4OTFPQ1NTqwRIFWTq52lq/jc0@A8A "R – Try It Online")
[Answer]
# JavaScript (ES6), 24 bytes
```
x=>x*Math.tan(Math.PI/x)
```
---
## Try it
```
o.innerText=(f=
x=>x*Math.tan(Math.PI/x)
)(+i.value);oninput=_=>o.innerText=f(+i.value)
```
```
<input id=i min=3 type=number value=3><pre id=o>
```
[Answer]
# [MATL](https://github.com/lmendo/MATL), 7 bytes
```
YPy/Z,*
```
[Try it online!](https://tio.run/##y00syfn/PzKgUj9KR@v/f0MDAA "MATL – Try It Online")
[Answer]
# [Japt](https://github.com/ETHproductions/japt/), 7 bytes
```
*MtMP/U
```
[Test it](https://ethproductions.github.io/japt/?v=1.4.5&code=Kk10TVAvVQ==&input=Mw==)
---
## Explanation
Just implements the forumla, where `Mt` is tan, `MP` is pi and `U` is the input.
[Answer]
# [Ohm v2](https://github.com/MiningPotatoes/Ohm), 7 bytes
```
απ/ÆT³*
```
**[Try it online!](https://tio.run/##y8/INfr//9zG8w36h9tCDm3W@v/fGAA "Ohm v2 – Try It Online")**
---
# How?
```
απ/ÆT³*   Full Program
απ        Push Pi.
  /       Divided by the input.
   ÆT     Tangent.
     ³*   Multiplied by the input.
          Implicitly output.
```
[Answer]
# Perl, 14 + 16 = 30
```
perl -MMath::Trig -ple'$_*=tan(pi/$_)'
```
14 bytes for the program proper, and 16 for the command line switches
[Answer]
# [var'aq](http://esolangs.org/wiki/Var%27aq), 51 bytes
```
'Ij latlh HeHmI' tam boqHa''egh qojmI' boq'egh cha'
```
## Explanation
```
'Ij        - read from STDIN
latlh      - duplicate top of stack
HeHmI'     - push PI onto stack
tam        - swap first 2 elements on stack
boqHa''egh - divide
qojmI'     - take tangent
boq'egh    - multiply
cha'       - print
```
[Answer]
# Common Lisp, 29 bytes
```
(lambda(n)(* n(tan(/ pi n))))
```
[Try it online!](https://tio.run/##S87JLC74r5GWX5SbWKJQoqBUp2NokKakoPFfIycxNyklUSNPU0NLIU@jJDFPQ1@hIFMhTxMI/psBMQA)
[Answer]
# [Python 2](https://docs.python.org/2/), 45 bytes
```
from math import*
n=input()
print n*tan(pi/n)
```
[Try it online!](https://tio.run/##K6gsycjPM/r/P60oP1chN7EkQyEztyC/qESLK882M6@gtERDk6ugKDOvRCFPqyQxT6MgUz9P8/9/Q1MDAwMA "Python 2 – Try It Online")
[Answer]
# [Pyth](https://pyth.readthedocs.io), 9 bytes
```
*.tc.n0Q2
```
**[Test suite.](https://pyth.herokuapp.com/?code=%2a.tc.n0Q2&test_suite=1&test_suite_input=3%0A6%0A10%0A20%0A99%0A1697%0A15000&debug=0)**
---
# How?
```
*.tc.n0Q2    Full program. Q means input.
    .n0      Pi. 
   c         Divided by:
       Q     The input.
 .t     2    Tangent.
*        Q   Multiply by the input.
             Output implicitly.
```
[Answer]
# [Gaia](https://github.com/splcurran/Gaia), 5 bytes
```
₵P÷ṫ×
```
[Try it online!](https://tio.run/##S0/MTPz//1HT1oDD2x/uXH14@v//xgA "Gaia – Try It Online")
---
# How?
```
₵P÷ṫ×   Full program.
₵P      Push Pi.
  ÷     Divided by the input.
   ṫ    Tangent.
    ×   Multiply by the input.
```
[Answer]
# [Swift](https://swift.org), 35 bytes
With compiler warnings:
```
import Foundation
{tan(M_PI/$0)*$0}
```
**[Try it here!](http://swift.sandbox.bluemix.net/#/repl/59ad330edd73eb75289a5491)**
Without compiler warnings, [**40 bytes**](http://swift.sandbox.bluemix.net/#/repl/59ad3360dd73eb75289a5492):
```
import Foundation
{tan(Double.pi/$0)*$0}
```
[Answer]
# Excel, 16 bytes
```
=A1*TAN(PI()/A1)
```
[Answer]
# [Prolog (SWI)](http://www.swi-prolog.org), 25 bytes
```
f(X,Y):-X is Y*tan(pi/Y).
```
[Try it online!](https://tio.run/##KyjKz8lP1y0uz/z/P00jQidS00o3QiGzWCFSqyQxT6MgUz9SUw8ipWCsqccFZpjBGIYGMJYRnGVpCZc1szSHs00NDIBKAA "Prolog (SWI) – Try It Online")
This is my first submission to codegolf, hope I'm doing alright. Written as a function.
[Answer]
# IBM/Lotus Notes Formula Language, 13 bytes
```
a*@Tan(@Pi/a)
```
Input taken via a field named a on the same form as the field containing the formula. No TIO available so screenshot of all test cases shown below:
[![enter image description here](https://i.stack.imgur.com/3RS6S.png)](https://i.stack.imgur.com/3RS6S.png)
[Answer]
# [PowerShell](https://github.com/TryItOnline/TioSetup/wiki/Powershell), 38 bytes
```
param($n)$n*[math]::tan([math]::pi/$n)
```
[Try it online!](https://tio.run/##K8gvTy0qzkjNyfn/vyCxKDFXQyVPUyVPKzo3sSQj1sqqJDFPA8YuyNQHSv7//9/QzNIcAA "PowerShell – Try It Online")
Does exactly what it says on the tin, just takes a little longer due to the lengthy `[math]::` .NET calls.
[Answer]
# [Ruby](https://www.ruby-lang.org/), 27 bytes
```
->n{n*Math.tan(Math::PI/n)}
```
[Try it online!](https://tio.run/##KypNqvyfZvtf1y6vOk/LN7EkQ68kMU8DxLCyCvDUz9Os/R9trKNgpqNgaKCjYATElpZAtpmlOZA0NTAwiNVLTUzOUKiuyatRKCgtKVZQUq7Oq43JU65Oi86LBTJi8pRq/wMA "Ruby – Try It Online")
[Answer]
# [Pari/GP](http://pari.math.u-bordeaux.fr/), 14 bytes
```
n->tan(Pi/n)*n
```
[Try it online!](https://tio.run/##FYexCoAgGAZf5cNJQ8mKDId8hvZocDGE@PkRl57ebLjjjmPJ5uaWsKORCTWSPPJIaqAWmZ9XEkwAl0y1p/hHIElSSuNcNJzGZDXmjve9nd@6V2vtpdoH "Pari/GP – Try It Online")
[Answer]
# [C# (Mono C# compiler)](http://www.mono-project.com/docs/about-mono/languages/csharp/), 24 bytes
```
=>n*Math.Tan(Math.PI/n)
```
[Try it online!](https://tio.run/##XY9PTwIxEMXPzqcot67RumjEkHVJDIIhASRC4sF4qN0Kjd0ptl3@hPDZ1@4CCfHWN/PevF@Fu84NmrJwCudkunVe5gmcKzZU@Ptv1DVaS@GVQcdeJEqrRAJCc@fIxJq55TnZATjPvRJkZVRGRlwhdd6GIx@fhNu5i4JlqJx/zEzxpWWHKFwW3pGUoFyT8w2NEpjWUeISyAzsgJDK2A39Rkv2JnkWKGUwXoD6po2Dmw3cuND61fbypd9SF0Uhd2hhT1lGQ3wlrWcz81wXVY4E9rBeqEo0UgzpMOkXKI4sVydYwbWoUIMj/PwoSkg7eDnifsFmHGn9mAxuMCoTOPb2je1xsaCbtHOif7fKyxq/usMGuDI/km6iA8y@vIMWNGO4jaHdhmar/QDN@ziO/wA "C# (Mono C# compiler) – Try It Online")
[Answer]
# [RPNGolf 0.6/0.7](http://github.com/pizzapants184/rpngolf), 12 bytes
```
tbp-1mBsdmcc
```
My first post using RPNGolf, my new stack-based language!
This is a full program that reads an integer from standard input and prints the output to standard output (without a trailing newline).
Explanation:
```
tb              # push user input from STDIN as int
  p             # duplicate top of stack
   -1           # push -1
     mB         # pop i, push inverse cosine of i
       s        # swap top two items on the stack
        d       # pop b, pop a, push a/b
         mc     # pop i, push tangent of i
           c    # pop b, pop a, push a*b
# RPNGolf implicity prints the stack upon normal exit
```
[Answer]
# [Factor](https://factorcode.org/), 19 bytes
```
[ pi over / tan * ]
```
[Try it online!](https://tio.run/##JY2xCsIwFEX3fMWdHWqiWIl@gLh0KU7iEMIrBu1LTF4FEb89Fh3POcMZnJeY66k/docdRifXxkcu4ljKD/9umNhLmANulJnuSJlEXikHFhR6TMSeCvZKvbFGC6Ox0rAWprVbmI3WGh9Vz0gB8UkZS8wLLHCpo0to6hc "Factor – Try It Online")
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), 7 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
žqI/Å¼*
```
[Try it online](https://tio.run/##yy9OTMpM/f//6L5CT/3DrYf2aP3/bwYA) or [verify all test cases](https://tio.run/##yy9OTMpM/V9Waa@k8KhtkoKSfeX/o/sKK/UPtx7ao/Vf53@0sY6ZjqGBjpGBjqWljqGZpbmOoamBgUEsAA).
**Explanation:**
```
žq       # Push PI (3.141592653589793)
  I/     # Divide it by the input
    Å¼   # Get the tangent of this
      *  # Multiply it by the (implicit) input
         # (after which the result is output implicitly)
```
[Answer]
# [Pyt](https://github.com/mudkip201/pyt), 6 bytes
```
Đπ/⅟ť*
```
[Try it online!](https://tio.run/##K6gs@f//yITzDfqPWucfXar1/7@hAQA "Pyt – Try It Online")
```
Đ            implicit input (n); duplicate on stack
 π           push pi
  /          divide n by pi
   ⅟         take the reciprocal
    ť        tan(pi/n)
     *       multiply by n; implicit print
```
]