+ 4
Speed comparison 'if' vs ' object referencing'
I came up with a way to reduce the amount of if's/checks. It works by constructing sth like a list, with every node storing a number. The first node is of a different class than the other nodes. Now when I call the n'th node to calculate factorial it only does this: return value * pre.factorial(); Since the first node is of a different class it only does this: return 1; The thing is it's not faster than the regular recursive factorial... https://code.sololearn.com/cdHL0h171eCZ/?ref=app
2 odpowiedzi
+ 3
ran out of question space...
so my question is:
why is it equally fast or even slower?? 😅
+ 1
does anyone have any guesses? 😅