What's new

Java shortening Help

Ten_Tacles

Level 42
Jul 5, 2010
991
0
Credits
18,110
Points
0
for(int i=0; i < Level; i++) {



Blockamount = Blockamount + ((((Level*2)-(i*2+1))*((Level*2)-(i*2+1)))*(i+1));

}



Basically, I want to shorten this function into a formula.

I just don't know how.

It is also very complicated >.<
 

The Noodle

Level 48
Aug 1, 2010
1,755
2
Credits
19,650
Points
0
((((1*2)-(i*2+1))*((1*2)-(i*2+1)))*(i+1)) + ((((2*2)-(i*2+1))*((2*2)-(i*2+1)))*(i+1)) ... ((((n*2)-(i*2+1))*((n*2)-(i*2+1)))*(i+1))
 

The Noodle

Level 48
Aug 1, 2010
1,755
2
Credits
19,650
Points
0
Code:
 ((((Level*2)-(i*2+1))*((Level*2)-(i*2+1)))*(i+1))



As it is the i variable that increases it should be n and not the power level which is over 9000 (a constant).
 

Ten_Tacles

Level 42
Jul 5, 2010
991
0
Credits
18,110
Points
0
Eh.

I have for each possible Spire four values.

Level, Height, Base size and Block amount.

I can calculate all missing values from Level Height (nearest Level) and Basesize, but Block amount is missing.
 
Top