public static void main(String[] args) {
int n = 8; //set anything here
for (int even = 2, odd = 1;even<=n;even+=2,odd+=2){
System.out.print(even+" "+odd+" ");
}
}
2
solved How I print the following sequence of numbers using for loop in java [closed]