/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package exercicipraentrega;
import java.util.Scanner;
/**
*
* @author franc
*
* - Entregar o números 1, 4, 5, e 7;
*
* 5. Criar um programa que irá determinar o n-ésimo termo da sequência: 3,5,8,12,17,23...
*
*/
public class Exercicio05 {
public static void main(String[] args) {
Scanner teclado = new Scanner(System.in);
System.out.println("Digite o numero digite o Número da posiçao do elemento da Progressão Aritmética");
int n1, valor1, ultimoNumero = 0;
final int base = 2;
valor1 = teclado.nextInt();
n1 = valor1;
// for (int i = 0; i <= n1; i++) {
// int r = ((2*n1)-i);
// ultimoTermo += a1 + ((n1 - a1)*r);
// System.out.println(ultimoTermo);
// }
for (int i = 0; i <= n1; i++) {
for (int j = 1; j <= n1; j++) {
ultimoNumero = base + n1 + i;
}System.out.println(ultimoNumero);
}
}
}
Alguem me ajuda a entender pq o laco esse for resulta em loop???
E pra esse exercicio ficar certo se caso usuario digitasse o numero 6 teria q retorna esse resultado 3,5,8,12,17,23.