17
2
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.
Can we also output
3.0
instead of3
? – Adnan – 2016-03-23T16:00:25.7732@AandN I guess... Make sure your program is correct for all inputs though, and does not suffer from floating point errors for big inputs. – orlp – 2016-03-23T16:06:19.360
Can we output
a
andb
as a rational type? – Alex A. – 2016-03-24T00:31:17.5072@AlexA. Only if the output clearly shows both integers. – orlp – 2016-03-24T00:48:50.740
@Dennis For this challenge I'll be lenient (poke around in chat history for discussion around this) and remove restrictions. – orlp – 2016-03-24T02:19:47.910
OK, thank you for clearing that up. – Dennis – 2016-03-24T02:21:05.797
"it's ok if your answer fails due to limitations in your language's integer type" TODO: write a language with a 1 bit integer type... – SamYonnou – 2016-03-24T15:18:42.030
1
@SamYonnou Those already exist, but abusing native number types to trivialize a problem is one of the loopholes that are forbidden by default.
– Dennis – 2016-03-25T03:46:14.853It wasn't mentioned in the original post, but
– orlp – 2016-12-28T10:56:57.707a/b
converges on 2/5. More info here: http://mathoverflow.net/questions/164092/computing-prod-p-fracp2-1p21-without-the-zeta-function.