Firstly, this sounds like a homework assignment, so do be aware of our homework policy, FAQ: Homework Policy
This kind of thing is pretty straightforward to do with R. Assuming this a homework question, could you let us know what you've attempted to do already, what issues you're having? Ideally, pose these with a reprex.
Also, I am not familiar with search.prime or cat prime, in either base-R or an R package on CRAN after a quick search. Could you set these up?