From fc7c248fafef4ba2aecf9dcf4718b3d4c91d94b0 Mon Sep 17 00:00:00 2001 From: Ian Coleman Date: Wed, 30 Nov 2016 19:38:14 +1100 Subject: Entropy with more than 4 decks can be calculated --- src/js/entropy.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/js/entropy.js b/src/js/entropy.js index b7274bb..24fc21a 100644 --- a/src/js/entropy.js +++ b/src/js/entropy.js @@ -263,7 +263,12 @@ window.Entropy = new (function() { } // Work out the total number of bits for this many decks // See http://crypto.stackexchange.com/q/41886 - var gainedBits = Math.log2(factorial(52 * numberOfDecks)); + var gainedBits = 0; + // Equivalent of Math.log2(factorial(52*numberOfDecks)) + // which becomes infinity for numberOfDecks > 4 + for (var i=1; i<=52*numberOfDecks; i++) { + gainedBits = gainedBits + Math.log2(i); + } var lostBits = 52 * Math.log2(factorial(numberOfDecks)); var maxBits = gainedBits - lostBits; // Convert the drawn cards to a binary representation. -- cgit v1.2.3