Challenge 39
🟨🟩🟦
Consecutive Cubes
Create a program to add and output the first 1000 triplets of 3 consecutive cubes - e.g.
Examples:
1 ** 3 + 2 ** 3 + 3 ** 3 = 36
2 ** 3 + 3 ** 3 + 4 ** 3 = 99
...
998 ** 3 + 999 ** 3 + 1000 ** 3 = ?
Extension:
Exponentiation is about 4-8x slower than addition depending on hardware, compiler optimisations etc. We can implement this same algorithm without needing to do 3 exponentiation operations each time. You can use the TIME() function to measure to time taken to execute the code. Is this new approach faster? (it might not be, since you may end up using MOD, IF statements (in which incorrect brand prediction can slow down code)) etc.
Try other sequences - pairs of squares, pairs of ** 4 numbers, quads of ** 4 numbers - are there any interesting patterns?