Advertisement
Guest User

Untitled

a guest
Oct 19th, 2019
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. # put your python code here
  2. def IsPrime(n):
  3. d = 2
  4. while n % d != 0:
  5. d += 1
  6. return d == n
  7.  
  8. ans = []
  9. a = []
  10. b = int(input())
  11. c = input().split()
  12. for i in c:
  13. a.append(int(i))
  14. for i in a:
  15. if IsPrime(i):
  16. ans.append(i)
  17. ans = ans[::-1]
  18. v = ""
  19. if not ans:
  20. print(0)
  21. else :
  22. for i in ans:
  23. v += str(i) + " "
  24. print(v)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement