Published:
Updated:


Solution

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Solution {
    public static int solution(int n) {
        for (int x = 1; ; x++) {
            if (n % x == 1) {
                return x;
            }
        }
    }

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        System.out.print(solution(n));
        br.close();
    }
}

Leave a comment