Codice PHP:
int n = 2;
//2^n
int n_2 = (int)Math.pow(2.0, n);
//2^2^n
int n_2_2 = (int)Math.pow(2.0, n_2);
int temp = 1;
for(int i = 0; i < n_2; i++){
for (int j = 0; j < n_2_2 ; j = j + temp){
for(int k = 0; k < temp ; k++){
if(((j / temp) % 2) == 0)
System.out.print("0");
else
System.out.print("1");
}
}
temp = temp * 2;
System.out.println();
}
Se n > 2 č giā difficile visualizzare il risultato...