0
Receive a value n
and print the following table using the structure chaining for
:
1
2 4
3 9 27
4 16 64 256
n n² n³ ... n^n
I tried to:
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("");
}
}
}
I posted a variable response based on your original question. Nothing prevents you from deleting the
r
and leave theMath.pow
inside the print– Bacco
Thank you so much for helping me! :)
– Emerson Araujo
@Emersonaraujo is welcome, I’m glad that the answer helped you with your question / problem, take advantage and make the [tour] to know how it works to community.
– NoobSaibot
Good that it was useful, the important thing is that with Edit, you clarified things you wouldn’t give with the original post. When you can, read [help] and [Ask], and always try to elaborate the question with the relevant details, so you can have a quick answer
– Bacco