#K41727. Smallest Divisor

    ID: 26930 Type: Default 1000ms 256MiB

Smallest Divisor

Smallest Divisor

Given a positive integer represented as a string num, find its smallest divisor strictly greater than 1. If the number is prime, then the smallest divisor is the number itself.

In mathematical terms, you are to find the smallest integer \(d > 1\) such that \(num \mod d = 0\). The input is provided as a string and can be very large (up to \(10^5\) digits). In our test cases the integer will be within a manageable range for standard data types.

Note: For languages with native arbitrary precision integers (like Python), conversion from string to integer is allowed. For others, it is guaranteed that the input number fits in the conventional 64-bit integer range.

inputFormat

A single line containing the string representation of the positive integer.

outputFormat

Output a single integer on one line: the smallest divisor of the given number (greater than 1).## sample

123456789101112
2