public class HelloWorld{ public static void main(String[] args) { long result = 0; long f = 1; for(int i = 1; f <= 99; i++){ result += f; f = f + 2; } System.out.printf("result = %d ",result); } }
计算结果
2500