Sum of the Squares Comments
Comments

@jacknerik, ^ does not do "power" in Java. You can see the Java's main builtin math operations here: http://www.learneroo.com/modules/11/nodes/103. Your way was good, though there is also the
Java Math library, which hasn't been covered yet. (You can see it over here: http://docs.oracle.com/javase/6/docs/api/java/lang/Math.html )

I've entered this code
for (int i = a; i <= b; i ++)
{
return (i * i);
}when I run the program it tells me I am missing a return statement.

for(int m=a; m<b; m=m+1){ if(m>a&&m<b){ return m*m+b*b+a*a
someone explain why my code is wrong.

Why is there no cheat button on this node? I can't figure this one out......sigh I would like a little bit of help before I give up on this one

Hint: Use a variable to keep track of the total sum and return that at the end.

ahhh okay thanks I think I can manage that. THANKS

@Learneroo I tried creating an int that represents the total. For some reason my int that represents the numbers in the range only picks up the first number in the set. Can you explain what I'm doing wrong?

Can I get the answer to this one.....I'm stumped......__

@Bernard, create a variable
sum
before the loop, and then add the square of each number tosum
. Then returnsum
after the loop. 
@learneroo when you say create a variable. Do you mean create an int variable? And if so I'm given only the first and last number how can I express the numbers in the range in an int? I was thinking a++.

Yes, create an int variable. Then loop through the numbers from a to b. If you need more help see this code and modify it to add the squares instead of the numbers. See also Math with loops for more practice.

@leaneroo when i plug in the provided code given in the above comment i get an error. I'm gonna work on it still just wanted to let you know. Thanks

@learneroo , Finally got it but I don't quite understand still. In my equation does sum remain zero even as the loop goes on. I recall in past nodes that sum changes as the loop goes on. I may be wrong though. Thanks

sum
is declared outside the loop and set to 0, the loop modifies its value, so after the loop it has the value of whatever it was at the end of the loop. See also scope. 
Why does this result in "Execution timed out. Please fix your code to execute faster."?
static int doStuff(int a, int b){ int sum = 0; for (int i=a;a<=b;i++) { int aPow = a*a; int bPow = b*b; sum += (aPow*bPow); } return sum; }

Check if the loop will ever terminate. Will there be cases where a will never be less than b, so that the loop goes on forever?

Thanks. I just reread my code after sleeping and can't believe I even wrote that.

sumsquare = function(a, b) {
base = a^{2}
for (i in (a+1):b) {
base = base + i^{2}
}
print(base)
}
Jacknerik
Dec 7, 4:44 PMDoes ^ not mean "to the power of" in java? I kept trying i^{2} but that didn't work, so I did i*i and that did.