I am working on a program where a user gives two numbers. The first is the number that the counter will count up to. The second is the increment it will do so. The program has a starting number of one and should add all the numbers together that add up the first given number. For example, The user inputs numbers 7 and 2. So the program should do the following: 1+3+5+7 and would equal 16. I cannot figure out what I am doing wrong with my program.
System.out.print("Please enter your first positive number: ");
int n1 = user.nextInt();
System.out.print("Please enter your second positive number: ");
int n2 = user.nextInt();
int sum = 1;
while(sum <= n1)
{
sum += n2;
}
System.out.println("Sum = " + sum);