I want to create a function so that it will find the integer a so that a <= n
.
If n
is 99
, then the program will return a = 3
.
This is because the function is finding the sums of the consecutive cubes.
So, 1 + 8 + 27 + 64 = 100
, which is more than 99
. But 1 + 8 + 27
is less than 99
, so a = 3
is the correct answer.
I was trying to do something like:
cubes = 0
for i in xrange(1, 1+x)
cubes += i*i*i
while cubes <= n
but I am very confused. How should I proceed?