Smallest Divisor (Function)#9398

Smallest Divisor (Function)

1 second
64 megabytes
Very easy

Given an integer , find the smallest natural divisor of greater than . The constraints are 2 \le x < 10^{14}.

Implement the following function:

This function should return the smallest divisor of that is greater than .

Here, type is an integer type appropriate for the problem's constraints (choose an appropriate type yourself).

Examples

  • For x = 2, the smallest divisor is .

  • For x = 9, the smallest divisor is .

Example 1

Loading
Loading