for(int j = 0; j < 40; j++) { int n = (((int)(j * Math.random())+2)/2)*2; System.out.printf("%2d ", n); if((j+1) % 8 == 0) System.out.println(); }