Advertisement
Guest User

Untitled

a guest
Nov 29th, 2015
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.41 KB | None | 0 0
  1. import math
  2. def is_simple(n):
  3.     if( n%2 == 0):
  4.         return False
  5.     i = 3
  6.     k =math.sqrt(n)
  7.     while n%i != 0 and i <= k:
  8.         i = i+2
  9.     return n%i != 0
  10.  
  11.  
  12. def is_polyndrom(n):
  13.     a = []
  14.     while n > 0:
  15.         d = n%10
  16.         n = int(n/10)
  17.         a.append(d)
  18.     return a[::1] == a[::-1]
  19.  
  20. n = int(input())
  21.  
  22. while is_polyndrom(n) == False or is_simple(n)==False:
  23.     n=n+1
  24. print(n)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement