📅  最后修改于: 2022-03-11 15:00:14.684000             🧑  作者: Mango
#include
#include
int smallest_divisor(int n) {
int i;
for (i = 2; i <= sqrt(n); ++i) {
if (n % i == 0) {
return i;
}
}
return n;
}
int main() {
int n;
printf("Enter a Number: ");
scanf("%d", &n);
printf("Smallest Divisor of %d = %d", n, smallest_divisor(n));
}