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*

2
  • \$\begingroup\$ Wow.. I know the default rule is "given any amount of memory and time", but your code already times out for n=10 in TIO.. :S That must be a very performance-heavy operation you're doing there. Is it the recursion that causes this, or is something else the bottleneck? \$\endgroup\$ Commented Nov 8, 2017 at 13:20
  • 2
    \$\begingroup\$ @KevinCruijssen the second condition basically apply the function on the range of 0..n-1, and considering the same apply for every call, that would come roughly at a huge O(2^n). of course it would be lower with a more reasonable code, but that's where the bottleneck sits \$\endgroup\$ Commented Nov 8, 2017 at 13:44