Speed comparison 'if' vs ' object referencing' | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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

24th Aug 2019, 2:34 PM
Anton Böhler
Anton Böhler - avatar
2 Answers
+ 3
ran out of question space... so my question is: why is it equally fast or even slower?? 😅
24th Aug 2019, 2:35 PM
Anton Böhler
Anton Böhler - avatar
+ 1
does anyone have any guesses? 😅
25th Aug 2019, 11:35 AM
Anton Böhler
Anton Böhler - avatar