Re:Functional Programming 101 with Haskell
by euph0ria on Friday January 24, 2014 @06:13AM
(#7114363)
Why is it not n! ?
[ Parent
| on HN ]
Re:Functional Programming 101 with Haskell
by winstonsmith on Friday January 24, 2014 @01:43PM
(#7116587)
It's actually [n!e] - 1 where [x] the greatest integer less than or equal to x and e is the base of the natural logarithm. As nbouscal points out, the total number of heads is H=n!(1+1/1!+ 1/(n-1)!). Using the Taylor series for e^x, H = n!e - n!(1/n! + 1/(n+1)! + ...) = n!e - 1 - r, where r = (1/(n+1) + 1/(n+1)(n+2) ...). The remainder term r is easily seen to be less than 1, and H is and integer, so H=[H+r]=[n!e]-1.
Re:Functional Programming 101 with Haskell
by nbouscal on Friday January 24, 2014 @01:03PM
(#7116304)
There will be n! of the smallest heads, the ones which don't spawn any new heads. Total heads, though, will be 9 + 9 * 8 + 9 * 8 * 7 + ...
Re:Functional Programming 101 with Haskell
by euph0ria on Sunday January 26, 2014 @03:52PM
(#7126840)
aargh, of course... thanks!
Re:Functional Programming 101 with Haskell
by tdinkar on Friday January 24, 2014 @10:12AM
(#7115200)
It's actually 9* (1 + 8 * (1 + 7 * (1 + 6 ..... + 1)))
Re:Functional Programming 101 with Haskell
by winstonsmith on Friday January 24, 2014 @01:21PM
(#7116425)
= [9!e] - 1
(because your expression expands to 9 + 9(8) + 9(8)(7) + ... 9! = 9!(1+1/1 + 1/2! + ... 1/8!) = -1 + 9! e - (1/10 + 1/(10 11) + ...))