I am new to this, I hope you can help me. The teacher has left us homework, a program that calculates the following sequence that has a behavioral pattern: 3, 5, 5, 8, 7, 11, 9, 14, 11, 17 ... with the condition that we add a limit for the generation of it: I came up with the code like this:
Scanner sc= new Scanner(System.in);
int n1= 3, n2= 5, rep;
System.out.println("Ingrese longuitud de la sucesión");
rep= sc.nextInt();
for(int i= 1; i <= rep; i++)
{
System.out.print(n1+ ", " + n2 + ", ");
n1= n1+2;
n2= n2+3;
}
getting generated this succession, but I have problems deploying this on the screen, not with the sequence, if not with the number of nueros in which it extends, example: rep (the number of terms I want to display in succession) = 2; When deferring the succession, I should stay: 5.3 and nothing else, but it happens to me that instead of displaying the above, it gives me 3, 5, 5, 8, four instead of the 2 that I specify by keyboard, that is, the double number that is specified as limit . So, how can I make this not happen and that it only displays the limit that sets it on the screen? Thank you very much in advance.