Both of these functions sum the integers from 0 to n. Are the runtimes respectively O(n) and O(1) or O(nlog(n)) and O(log(n)) since performing arithmetical operations on larger numbers takes longer?def sum1(n):
result = 0
for i in range(n + 1):
result += i
return result
def sum2(n):
return (n ** 2 + n) // 2
I dont know
you're not the boss of me now
>>55964624
Technically it's O(nlog(n)) and O(log(n)) but for practical values of n the arithmetical operations take a vanishingly small amount of time and can be neglected giving O(n) and O(1).
O(2^(n!))