Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

📚 The CoCalc Library - books, templates and other resources

132939 views
License: OTHER
1
public class Euler28 {
2
public static void main(String[] args) {
3
int sum1 = 0, sum2 = 0;
4
int n = 3;
5
int m = 2;
6
for (int i = 0; i < 500; i++) {
7
sum1 += (n * n) + ((n * n) - (n - 1));
8
n += 2;
9
10
sum2 += (((m * m) + 1) + ((m * m) - (m - 1)));
11
m += 2;
12
}
13
System.out.println("result: " + (sum1 + sum2 + 1));
14
}
15
}
16
17