View Code of Problem 80

import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		while (scan.hasNext()) {
			int n = scan.nextInt();
			if (n == 0) {
				break;
			}
			int cur = 0;
			for (int i = 1; i <= n; i++) {
				cur = (cur+3)%i;
			}
			System.out.println(cur+1);
		}
	}
}

Double click to view unformatted code.


Back to problem 80