PROBLEM STATEMENT:
Class name: CountBy
Method name: countBy
Parameters: int, int, int
Returns: int
Implement a class CountBy, which contains a method countBy. This method will
return an int that represents the sum of all the numbers from one number
(inclusive) to another number (inclusive) counting by a third number.
The method signature is:
int countBy(int fromNum, int toNum, int byNum);
Be sure you method is public.
TopCoder will ensure the validity of the inputs. Inputs are valid if all of the
following criteria are met:
*The fromNum will have a value from -500 to 500 inclusive.
*The toNum parameter will have a value from -500 to 500 inclusive.
*The byNum parameter will have a value from 1 to 1001 inclusive.
Notes:
*The toNum parameter can be lower than the fromNum parameter - in which case,
you are counting down by the byNum.
Examples:
-if the input is {10,20,2}, you would count the numbers 10,12,14,16,18,20 and
return their sum 10+12+14+16+18+20 = 90
-if the input is {10,21,2}, you would count the numbers 10,12,14,16,18,20 and
return 90
-if the input is {10,22,2}, you would count the numbers 10,12,14,16,18,20,22
and return 112
-if the input is {10,0,2}, you would count the numbers 10,8,6,4,2,0 and return 30
-if the input is {10,-1,2}, you would count the numbers 10,8,6,4,2,0 and return
30
-if the input is {10,-2,2}, you would count the numbers 10,8,6,4,2,0,-2 and
return 28
-if the input is {10,20,30}, you would return 10
-if the input is {10,10,1}, you would return 10