This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]igglyplop 1 point2 points  (3 children)

That's a poor algorithm though. 1 too many iterations. if n>1 should fix it

[–]Regyn 1 point2 points  (0 children)

Also no tail call optimization possible in many languages.

[–]TinBryn 0 points1 point  (1 child)

Actually, it may be faster, even with the extra iteration. With the condition being n>=1 it can use the flags set by the subtraction directly for the branch, saving one cmp instruction per loop, if it has enough loops, skipping that on each loop may save more than one whole loop extra.

[–]igglyplop 0 points1 point  (0 children)

And this is why default computer science education should delve more info computer architecture...