Skip to content

Instantly share code, notes, and snippets.

@Strikeskids
Last active August 29, 2015 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Strikeskids/11463140 to your computer and use it in GitHub Desktop.
Save Strikeskids/11463140 to your computer and use it in GitHub Desktop.
final Scanner in = new Scanner(System.in);
System.out.println("Enter initial value of i: ");
while(!in.hasNextInt()){
in.next();
}
int i = in.nextInt();
in.close();
int len = State.values().length;
IntStream stream = IntStream.iterate(i, (i) -> State.values()[(i%len + len)%len].update(i));
while ((i = stream.nextInt()) >= 0) {
System.out.printf("i: %d%n", i);
}
System.out.printf("Final value is: %d", i);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment