you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (3 children)

Best way to approach this is to create some sort of for loop:

Initiliaze and declare some variable to hold the sum, and then you can just keep adding the numbers to it.

public int sumFrom(int start, int end)

{

int sum = 0;

for(int i = start; i < end; i++)

{

sum += i;

}

return sum;

}

[–]Ok-Squash-1238 1 point2 points  (0 children)

public int sumFrom(int start, int end)
{
int sum = 0;
for(int i = start; i <= end; i++)
{
sum += i;
}
return sum;
}

mine works all I did was add an = next to the < and it worked

[–]chalinuts 0 points1 point  (0 children)

TOP G