Advertisement
Josif_tepe

Untitled

Oct 14th, 2024
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.73 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.     return str(x) == str(x)[::-1]
  12. def main():
  13.  
  14.  
  15.  
  16.     n = int(input())
  17.     niza = []
  18.  
  19.     for i in range(0, n):
  20.         x = int(input())
  21.         niza.append(x)
  22.  
  23.     prosti = 0
  24.     slozheni = 0
  25.     palindromi = 0
  26.  
  27.     for i in range(0, n):
  28.         if dali_e_prost(niza[i]):
  29.             prosti += 1
  30.         else:
  31.             slozheni += 1
  32.  
  33.         if e_palindrom(niza[i]):
  34.             palindromi += 1
  35.  
  36.     print(f"Prosti: {prosti}")
  37.     print(f"Slozheni: {slozheni}")
  38.     print(f"Palindromi: {palindromi}")
  39.  
  40.  
  41. if __name__ == "__main__":
  42.     main()
  43.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement