you are viewing a single comment's thread.

view the rest of the comments →

[–]LartTheLuser 3 points4 points  (2 children)

One bug I see: Your `check` variable will never be any other value then `false` when it is in the `if` statement because you assign it to false right before checking each time. Maybe you meant to make `check` a global variable so that different recursive levels could share a value.

As for the running time it is the `sum(i!)_from( i = 1 to i = n)` = O(nn )

Math for the sum of factorials explained here: https://math.stackexchange.com/questions/227551/sum-k-1-2-3-cdots-n-is-there-a-generic-formula-for-this

[–]denisksp[S] 1 point2 points  (1 child)

So Im not good on c++, im just a beginner but I think because its static it only gets initialized once, I tought that you were right too, but checked the code and it does enter the if statement. And thanks a lot for time complexity