Advertisement
Josif_tepe

Untitled

Oct 14th, 2024
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.78 KB | None | 0 0
  1. import math
  2. def dali_e_prost(x):
  3.     for i in range(2, int(math.sqrt(x) + 1)):
  4.         if x % i == 0:
  5.             return False
  6.  
  7.     return True
  8.  
  9.  
  10. def e_palindrom(x):
  11.     s = str(x)
  12.     if s == s[::-1]:
  13.         return True
  14.  
  15.     return False
  16. def main():
  17.  
  18.  
  19.  
  20.     n = int(input())
  21.     niza = []
  22.  
  23.     for i in range(0, n):
  24.         x = int(input())
  25.         niza.append(x)
  26.  
  27.     prosti = 0
  28.     slozheni = 0
  29.     palindromi = 0
  30.  
  31.     for i in range(0, n):
  32.         if dali_e_prost(niza[i]):
  33.             prosti += 1
  34.         else:
  35.             slozheni += 1
  36.  
  37.         if e_palindrom(niza[i]):
  38.             palindromi += 1
  39.    
  40.     print(f"Prosti: {prosti}")
  41.     print(f"Slozheni: {slozheni}")
  42.     print(f"Palindromi: {palindromi}")
  43.  
  44.  
  45. if __name__ == "__main__":
  46.     main()
  47.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement