Background
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.
Goal
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).
Test cases
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)
Rules
- Standard loopholes are forbidden.
- Input and output may be in any
convenient format. You may output
f(k)
as a stringnumerator/denominator
, as a tuple of two integers, a fraction or rational object, etc. If you output a string, give two integers only, that is, output3/2
instead of1 1/2
. - This is code-golf, the shortest answer (in bytes) wins.
atan(0)
term is unnecessary. \$\endgroup\$