Originally Posted by

**amor_vincit_omnia** For a homework problem I need to use a code to compute the sum of the integers from 1 to 5,000

can someone help me or direct me to another site that can? Thanks.

I know that C++ and Java are similar. I can give you the code to the program what you are looking for in Java, but you will need to make the proper conversion over to C++.

Code:

public class sum{
public static void main(String [] args){
// This part computes the sum 1+2+3+...+4999+5000
int sum=0, cntr;
for (cntr=1; cntr <= 5000; cntr++)
sum += cntr;
System.out.println (sum);
}
}

I hope this somewhat helps.

--Chris