5 ms·
Using max possible days in month gives ~21 million js: [...Array(31).keys()] .map(num => Math.pow(2,num)) .reduce((total,num) => total + num) / 100
by twistedpairs 7y ago
Using max possible days in month gives ~21 million
js:
[...Array(31).keys()]
.map(num => Math.pow(2,num))
.reduce((total,num) => total + num)
/ 100
$21,474,836.47
or since the sum is equal to the next sequential (2 to power of n+1) minus 1 cent => 2^31 - 1 = $21,474,836.47