Created
June 11, 2011 22:05
-
-
Save sachin-handiekar/1021005 to your computer and use it in GitHub Desktop.
Interview Question - InfiniteSeries
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class InfiniteSeries { | |
public static void main(String[] args) { | |
int i = 100; | |
while (true) { | |
if (i > 0) { | |
System.out.println((100 - i) + " " + i); | |
i--; | |
} else if (i == -100) { | |
System.out.println((100 + i) + " " + 0); | |
i--; | |
} else if (i >= -101 || i >= -200) { | |
System.out.println((-i - 100) + " " + (-i - 100)); | |
i--; | |
} else { | |
i = 100; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Write a program to print the following series, using the following condition -