# Answer to Question #65449 in Java | JSP | JSF for gazibo

Question #65449

2. Write an application that sums the integers from 1 to 50 (That is, 1+2+3…+50). Save the file as Sum50.java.

Expert's answer

public class Sum50 {

public static void main(String[] args) {

int sum=0;

for(int a=0; a<=50; a++)

{

sum+=a;

}

System.out.println("The sum of 1 from 50 is: " +sum);

}

}

public static void main(String[] args) {

int sum=0;

for(int a=0; a<=50; a++)

{

sum+=a;

}

System.out.println("The sum of 1 from 50 is: " +sum);

}

}

Need a fast expert's response?

Submit orderand get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

## Comments

## Leave a comment