[Solved] How I print the following sequence of numbers using for loop in java [closed]

[ad_1]

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

[ad_2]

solved How I print the following sequence of numbers using for loop in java [closed]