Computer Science, asked by anindyaadhikari13, 3 months ago

0 2 0 2 0 2..

Print this series without using any string approach or conditional construct.
Write in Java. ​

Answers

Answered by Oreki
14

import java.util.Scanner;

public class Series {

public static void main(String[ ] args) {

System.out.print("Enter N - ");

int N = new Scanner(System.in).nextInt( );

for (int i = 0; i < N * 2; i += 2)

System.out.print((i & 2) + " ");

}

}

Similar questions