Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

4
  • \$\begingroup\$ Instead of summing from 1 to x-1 you could sum from 0 to x-2 then you could write f(i) instead of f(x-1-i). (I don't speak JavaScript, so I don't know whether it makes the code any shorter.) \$\endgroup\$ Commented Jan 6, 2022 at 7:27
  • \$\begingroup\$ @loopywalt I had tried many variance, but not so lucky. As the most byte costing part is calculate the combination (JS don't have built-in for combination number. It have to be multiplied manually during the loop), finger out stop condition, and make these codes be harmony with the special case for f(0). \$\endgroup\$ Commented Jan 6, 2022 at 7:33
  • \$\begingroup\$ 43 bytes \$\endgroup\$ Commented Jan 6, 2022 at 7:47
  • \$\begingroup\$ @att I'm not sure how f(i-1) part comes in your formula. But seems f=(n,i=n)=>i?--i&&f(n,i)*i/(n-i)+f(n+~i):1 also yield correct result (with 42 bytes) \$\endgroup\$ Commented Jan 6, 2022 at 8:15