public class NumberCount { /**
 * @param args
 */
public static void main(String[] args) {
// TODO Auto-generated method stub
int a = 3;
int b = 89;
int k =0;
for(;a<=b;a++){
if(a%3==0){
if(k>0&&k%5==0){
    System.out.println(a);
    k++;
}else{
System.out.print(a+" ");
k++;
}
}
}
}
}
=============================================================
3 6 9 12 15 18
21 24 27 30 33
36 39 42 45 48
51 54 57 60 63
66 69 72 75 78
81 84 87