answersLogoWhite

0

A Sample java method that can do this sum of all numbers between 1 to 50

public int sumNumbers(){

int retVal = 0;

for(int i = 0; i <=50; i++){

retVal = retVal + i;

}

return retVal;

}

User Avatar

Wiki User

15y ago

What else can I help you with?

Related Questions

draw a flowchart to read a number in and print all its divisors?

Hi


1 Draw a flowchart to read a number N and print all its divisors?

startn=0n=n/1


How to draw a flowchart to check if a number is a perfect square?

To draw a flowchart to check if a number is a perfect square, you would start with a start/end symbol. Then, you would input the number to be checked. Next, you would use a decision symbol with a condition to check if the square root of the number is an integer. If it is, the flowchart would output that the number is a perfect square; if not, it would output that the number is not a perfect square. Finally, you would end the flowchart.


How do you find the average between integers?

To find the average of integers, add them all together then divide the total by the number of integers.


How do you draw a flowchart to find maximum and minimum of given 3 input numbers?

You draw a flowchart to find maximum and minimum of given 3 input numbers by using all three numbers. You take the low, high and input the middle number between them. You can see the rise, or decline of the chart that way.


Write an algorithm to print the factorial of given number and then draw the flowchart?

write an algorithm to print the factorial of a given number and then draw the flowchart. This looks like someones homework, defiantly someone looking for the easy way. When it comes to programming, the more you do the better you get. Experience counts (making your own mistakes and learning from the mistake).


What is the sum of the integers from -30 to 50 inclusive?

810. All of the integers from -30 to30 cancel each other out by adding a negative to a positive. Then all you need to do is add the integers from 31 to 50. (31 + 32 + ....+50)


How does a Venn diagram show that all integers and all whole numbers are rational?

For example, 0 is an integer and whole number that is rational


Draw a flowchart that will determine and display the largest among the three numbers being inputted?

start input A &amp; B if A&gt;B print A is greatest if B&gt;A print B is greatest stop james ola writes.....SOT.


Draw a flowchart that will compute and display the Area of a rectangle using the formula: Area = Length Width?

The formula for the perimeter of a rectangle is: p = 2(l + w) In other words, just add all four sides. You can't calculate the perimeter of the rectangle if you know only the length.


What is the sum of the integers in the square grid that are equal to the given integer value?

To find the sum of integers in a square grid that match a given value, add up all the matching integers in the grid.


Draw algorithm and flowchart to check a number is perfct or not?

1. List all factors of number (including 1 and the number, list each factor only once even if it goes in multiple times) 2. Add up all the factors 3. If the sum is equal to twice the original number, then the original number is perfect, if not, it is not perfect.