Get a n
value and print the following table using the for
:
1
2 4
3 9 27
4 16 64 256
n n² n³ ... n^n
I tried:
import java.util.Scanner;
public class Questao4 {
public void Cadeia() {
Scanner num = new Scanner(System.in);
System.out.printf("Informe um número: ");
int n = num.nextInt();
for (int i = 1; i < n; i++) {
for (int j = 1; j < n; j++) {
System.out.println(Math.pow(i,j) + "");
}
System.out.println("");
}
}
}