Wow, I sure have a bunch of questions anyway here is my code
def mult(number, times):
total = 0
while times > 0:
total += number
times -= 1
return total
# This function returns the number to the exponent power.
def power(number, exponent):
total = 1
# Complete the function.
while exponent > 0:
total += number
exponent -= 1
return total
# Don't change the following code
# You can find coefficients for the equation on the tower
tower = hero.findFriends()[0]
a = tower.a
b = tower.b
c = tower.c
d = tower.d
x = hero.pos.x
while True:
# To find the path use a cubic equation
y = a * power(x, 3) + b * power(x, 2) + c * power(x, 1) + d * power(x, 0)
hero.moveXY(x, y)
x = x + 5
actually, that didnt work… I least I think it didn’t here is my code now
def mult(number, times):
total = 0
while times > 0:
total += number
times -= 1
return total
# This function returns the number to the exponent power.
def power(number, exponent):
total = 1
# Complete the function.
while exponent > 0:
print('begin iteration: total=' + str (total) + 'exponent='+str(exponent))
total = total
exponent -= 1
print('end iteration total =' + str (total) + 'exponenet='+str(exponent))
return total
# Don't change the following code
# You can find coefficients for the equation on the tower
tower = hero.findFriends()[0]
a = tower.a
b = tower.b
c = tower.c
d = tower.d
x = hero.pos.x
while True:
# To find the path use a cubic equation
y = a * power(x, 3) + b * power(x, 2) + c * power(x, 1) + d * power(x, 0)
hero.moveXY(x, y)
x = x + 5
Type Ctrl+Shif+I to open Debug in Browser
Click on Console
If you type as shown above the result will be similar to:
begin iteration: total=1; exponent=3
end iteration: total=10; exponent=2
begin iteration: total=10; exponent=2
end iteration: total=100; exponent=1
begin iteration: total=100; exponent=1
end iteration total=1000; exponent=0
the total is 1000 = 101010
and your code returns this:
begin iteration: total=1exponent=3
end iteration total =1exponenet=2
begin iteration: total=1exponent=2
end iteration total =1exponenet=1
begin iteration: total=1exponent=1
end iteration total =1exponenet=0
the total is 1
Congratulations @Luke10 - for the first time you don’t like every post!