OFFSET
1,5
COMMENTS
a(n) is the number of ways in which you can load a revolver with n chambers so that if a person survives after the first shot, he/she has better chances of survival for the second shot if the shooter continues rather than spins. a(n) <= A000031(n) as A000031(n) gives the number of possible revolver loadings.
LINKS
Tanya Khovanova, Heard on the Street
EXAMPLE
Based on the famous interview question where the revolver has six chambers and the shooter loads two adjacent bullets. As the answer to this question is to continue, a(6) must be at least 1.
MATHEMATICA
<< Combinatorica` colors[x_] := Table[PadLeft[Table[1, {n, i}], x], {i, 0, x}] continueBetter[list_] := (len = Length[list]; c0 = 0; c00 = 0; rotateN = 0; While[rotateN < len, newList = RotateLeft[list, rotateN]; If[newList[[1]] == 0, c0++; If[newList[[2]] == 0, c00++ ]]; rotateN++ ]; If[c0 > 0, c00/c0 > c0/len, False]) continueNum[num_] := (neckNum = Length[colors[num]]; ans = 0; count = 1; While[count <= neckNum, ans = ans + Length[Select[ListNecklaces[num, colors[num][[count]], Cyclic], continueBetter[ # ] &]]; count++ ]; ans) Table[continueNum[n], {n, 2, 15}]
PROG
(PARI) { a(n) = sum(z=0, n, sum(r=1, min(ceil(z-z^2/n)-1, n-z), sumdiv(gcd([n, z, r]), d, eulerphi(d) * binomial(z/d - 1, r/d - 1) * binomial((n-z)/d - 1, r/d - 1) )/r )) } \\ Max Alekseyev, Sep 25 2009
CROSSREFS
KEYWORD
nonn,uned
AUTHOR
Tanya Khovanova, Sep 23 2009
EXTENSIONS
Extended by Max Alekseyev, Sep 25 2009
STATUS
approved