# Find the tangent of the sum of inverse tangents

## Python 2, ~~76~~ 72 bytes

```
from fractions import*
f=lambda k:Fraction(k and(k+f(k-1))/(1-k*f(k-1)))
```

Use the identity:

```
tan(A + B) = (tan(A) + tan(B)) / (1 - tan(A) * tan(B))
```

We have:

```
f(k) = 0 if k = 0
= (k + f(k - 1)) / (1 - k * f(k - 1)) if k > 0
```

Try it online!

Thanks to Luis Mendo, save 4 bytes.

## Mathematica, 28 bytes

```
Fold[+##/(1-##)&,0,Range@#]&
```

Try it online!

A longer, but more interesting approach (32 bytes):

```
Im@#/Re@#&@Product[1+n I,{n,#}]&
```

Try it online!

## M, 11 bytes

```
×C÷@+
R0;ç/
```

Try it online!

Uses the OEIS formula `x(n) = (x(n-1)+n)/(1-n*x(n-1))`

with `x(0) = 0`

.