What's new

Java shortening Help

Ten_Tacles

Level 42
Joined
Jul 5, 2010
Messages
991
Reaction score
0
Credits
24,810
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
Joined
Aug 1, 2010
Messages
1,755
Reaction score
2
Credits
29,550
((((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
Joined
Aug 1, 2010
Messages
1,755
Reaction score
2
Credits
29,550
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).
 

Woody2371

Level 47
Joined
Jan 29, 2011
Messages
1,492
Reaction score
1
Credits
9,652
But he's right, it's a sequence not a formula, as far as programming goes that's basically as short as it gets
 

Ten_Tacles

Level 42
Joined
Jul 5, 2010
Messages
991
Reaction score
0
Credits
24,810
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