Read here prime numbers
I think it's fair to provide what you tried by now, and someone will correct it if not working. Otherwise you won't understand.
Check here is also a similar problem. Good luck
It looks like you're new here. If you want to get involved, click one of these buttons!