Advertisement
TwITe

Stepik_Task_10

Jul 24th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.27 KB | None | 0 0
  1. //goo.gl/mohDkE
  2. #include <iostream>
  3. #include <cmath>
  4. using namespace std;
  5.  
  6. int MinDivisor(int n) {
  7.     for (int i = 2; i < sqrt(n); i++) {
  8.         if (n % i == 0) {
  9.             return i;
  10.         }
  11.     }
  12.     return n;
  13. }
  14.  
  15. int main() {
  16.     int n;
  17.     cin >> n;
  18.     cout << MinDivisor(n);
  19.     return 0;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement