JAVA
java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
public class Program
{
public static void main(String[] args) {
int i,sum=0;
for(i=1000;i>=1;i--)
{
if(i%2==0)
sum+=i*i;
else
sum-=i*i;
}
System.out.println(sum);
}
}
/**
This is a solution to a question on Brainly.
Find the sum of
1000²-999²+998²-997²...+2²-1².
Who gonna do it on pen and paper when you got a friend like Java...
Do comment on the code if you want me to base it on user input...
*/
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run