1. ## Strange equation

I have come across this equation in a puzzle and I don't even know what it is, never mind the answer. Can any one help me, please?
Here it is: -

sum = 0
Do n = 123 To 321 Step 3
sum = sum + n
Loop n
Display sum

2. It's asking for the sum 123 + 126 + 129 + ... + 312.

3. ## Strange equation

Thank you for your help. When I'm faced with equations like that I think my mind just shuts down.

4. This is fairly simple actually:

There are 67 terms in the sequence: floor((321-123)/3) + 1 = 67
The sequence starts at 123
The sequence ends at 321: 3 * floor((321-123)/3) + 123
The average term is (123 + 321) / 2 = 222
The total is going to be average term * number of terms = 222 * 67 = 14874

I've verified this total with a small piece of Java code that doesn't take the above shortcut:

Code:
		long sum = 0;
for (long test = 123; test <= 321; test += 3) {
sum += test;
}
System.out.println("sum = " + sum);