Write a for statement to compute the sum 1 + 22 + 32 + 42 + 52 + ... + n2.

What will be an ideal response?


```
sum = 0;
for( i=1; i<=n; i++){
sum += i*i;
}
System.out.println("The sum is " + sum);
```

This code is in Fragments.java.

Computer Science & Information Technology

You might also like to view...

What is this symbol : called?

A. Scoping operator. B. Directional operator. C. Inheritance operator. D. Binary operator.

Computer Science & Information Technology

Double-clicking a macro in the Navigation Pane will ________ the macro

A) do nothing to B) run C) open D) delete

Computer Science & Information Technology

StubHub! is an example of a real-world C2C e-commerce site.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology

A(n) ____________________ is a document that summarizes your qualifications for a job.

Fill in the blank(s) with the appropriate word(s).

Computer Science & Information Technology