It can be shown that for any integer
k >= 0,
f(k) = tan(atan(0) + atan(1) + atan(2) + ... + atan(k)) is a rational number.
Write a complete program or function which when given
k >= 0, outputs
f(k) as a single reduced fraction (the numerator and denominator are coprime).
The first few values are
f(0) = (0,1) f(1) = (1,1) f(2) = (-3,1) f(3) = (0,1) f(4) = (4,1) f(5) = (-9,19) f(6) = (105,73)
- Standard loopholes are forbidden.
- Input and output may be in any
convenient format. You may output
f(k)as a string
numerator/denominator, as a tuple of two integers, a fraction or rational object, etc. If you output a string, give two integers only, that is, output
- This is code-golf, the shortest answer (in bytes) wins.