Unnecessary work
Technical Questions
Print all positive integer solutions to the equation
a3 + b3 = c3 + d3, (1 ≤ a, b, c, d ≤ 1000)
n = 1000
for a from 1 to n
for b from 1 to n
for c from 1 to n
for d from 1 to n
if a3 + b3 == c3 + d3
print a, b, c, d
O(N4)
n = 1000
for a from 1 to n
for b from 1 to n
for c from 1 to n
for d from 1 to n
if a3 + b3 == c3 + d3
print a, b, c, d
break
O(N4)
n = 1000
for a from 1 to n
for b from 1 to n
for c from 1 to n
d = pow(a3 + b3 - c3, 1/3)
if a3 + b3 == c3 + d3
print a, b, c, d
O(N3)
42
a3 + b3 - c3 = d3