A curious prime fraction formula Given a positive integer n output the integers a and b (forming reduced fraction a/b) such that:



Where pk is the k th prime number (with p1 = 2).

Examples:

1   -> 3, 5
2   -> 12, 25
3   -> 144, 325
4   -> 3456, 8125
5   -> 41472, 99125
15  -> 4506715396450638759507001344, 11179755611058498955501765625
420 -> very long

Probabilistic prime checks are allowed, and it's ok if your answer fails due to limitations in your language's integer type.



Shortest code in bytes wins.
Mathematica, 32 bytes

1##&amp;@@(1-2/(Prime@Range@#^2+1))&amp;


An unnamed function that takes integer input and returns the actual fraction.

This uses the fact that (p2-1)/(p2+1) = 1-2/(p2+1). The code is then golfed thanks to the fact that Mathematica threads all basic arithmetic over lists. So we first create a list {1, 2, ..., n}, then retrieve all those primes and plug that list into the above expression. This gives us a list of all the factors. Finally, we multiply everything together by applying Times to the list, which can be golfed to 1##&amp;.

Alternatively, we can use Array for the same byte count:

1##&amp;@@(1-2/(Prime~Array~#^2+1))&amp;