Smallest Divisor (Function)
Very easy
Execution time limit is 1 second
Runtime memory usage limit is 64 megabytes
Given an integer x, your task is to find the smallest natural divisor of x that is greater than 1. The constraints are 2 ≤ x < .
Implement the following function:
function solve(x: type): type; // Pascal
type solve(type x) // C++
def solve(x) // Python
This function should return the smallest divisor of x.
type - an integer type that is appropriate for the problem's constraints (to be determined).
Example:
For the number 2, the smallest divisor is 2.
For the number 9, the smallest divisor is 3.
Examples
Input #1
Answer #1
Submissions 3K
Acceptance rate 18%