Quantcast
Channel: which one is faster 5+5+5+5+5 or 5*5? - Stack Overflow
Viewing all articles
Browse latest Browse all 9

Answer by Andreas Dolk for which one is faster 5+5+5+5+5 or 5*5?

$
0
0

We should compare time complexity. The function is f1(n) = n * c, the equivalent f2(n) = Sum[1->n] c.

The complexity for multiplication is O(1) (constant time, one calculation for any n), the complexity for addition is O(n) (linear time, number of additions is equal to n).


Viewing all articles
Browse latest Browse all 9

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>