Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # put your python code here
- def IsPrime(n):
- d = 2
- while n % d != 0:
- d += 1
- return d == n
- ans = []
- a = []
- b = int(input())
- c = input().split()
- for i in c:
- a.append(int(i))
- for i in a:
- if IsPrime(i):
- ans.append(i)
- ans = ans[::-1]
- v = ""
- if not ans:
- print(0)
- else :
- for i in ans:
- v += str(i) + " "
- print(v)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement