/*
 * Loops.java
 *
 * Computer Science E-22
 */

public class Loops {

    private static int count;

    public static void mystery1(int n) {
        for (int i = 0; i < n; i++) {
            count++;
        }
    }

    public static void mystery2(int n) {
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                count++;
            }
        }
    }

    public static void mystery3(int n) {
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < 3; j++) {
                count++;
            }
        }
    }

    public static void mystery4(int n) {
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                for (int k = 0; k < n; k++) {
                    count++;
                }
            }
        }
    }

    public static void mystery5(int n) {
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < i; j++) {
                count++;
            }
        }
    }

    public static void main(String[] args) {
        int n = 10;
        if (args.length > 0) {
            try {
                n = Integer.parseInt(args[0]);
            } catch (NumberFormatException ignored) { }
        }

        mystery1(n);
        System.out.printf("mystery1: %d%n", count);

        count = 0;
        mystery2(n);
        System.out.printf("mystery2: %d%n", count);

        count = 0;
        mystery3(n);
        System.out.printf("mystery3: %d%n", count);

        count = 0;
        mystery4(n);
        System.out.printf("mystery4: %d%n", count);

        count = 0;
        mystery5(n);
        System.out.printf("mystery5: %d%n", count);
    }
}
