Challenge
You are given the following function:- which is the same as:-
with the base cases q(r, b, L) = 1 whenever r ≤ L, q(r, 0, L) = 0, if r > L and q(r, 0, L) = 1, if r ≤ L.
Your task is to code a program that takes r as input, and outputs the value of q(r, r - L, L) for all L taking integer values from 1 to (r-1), where r is any nonnegative integer.
Example 1
Input
Enter the value of r: 2
Output
q(2,1,1) = 0.3333333333
Example 2
Input
Enter the value of r: 3
Output
q(3,2,1) = 0.1
q(3,1,2) = 0.5
Winning criterion
The code that can correctly output q(r, r-L, L) for all L taking integer values from 1 to (r-1), for the highest value of r, in less than 300 seconds. In case of a tie, the code with lesser runtime will be considered. As this is a runtime-based challenge, I shall test all submissions on my machine.
r < L
andb = 0
? And what value ofb
will be used in the winning criterion? – Peter Taylor Dec 7 '14 at 23:21q(r, r-1, 1) == 2(r!)^2/(2r)!
(oeis.org/A001700) andr(r, 1, r-1) == (r-1)/(r+1)
(trivial). Haven't checked the others yet. – kennytm Dec 8 '14 at 17:23q(r,r-1,1)
is the reciprocal of A001700. – Peter Taylor Dec 10 '14 at 10:12