Advertisement
Guest User

Untitled

a guest
Oct 20th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.54 KB | None | 0 0
  1. import math
  2.  
  3. n = int(input())
  4.  
  5.  
  6. def isInt(n):
  7.     return int(n) == float(n)
  8.  
  9.  
  10. def MinDivisor(n):
  11.     d = 2
  12.     sqr = math.sqrt(n)
  13.     if isInt(sqr):
  14.         for d in range(d, n-1):
  15.             if n % d == 0:
  16.                 return d
  17.             if d > sqr:
  18.                 return d
  19.             d += 1
  20.         return d
  21.     else:
  22.         for d in range(d, n-1):
  23.             if n % d == 0:
  24.                 return d
  25.             d += 1
  26.         return d
  27.  
  28.  
  29. if MinDivisor(n) == n-1:
  30.     print(n)
  31. else:
  32.     print(MinDivisor(n))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement