Prime numbers in rstudio

How can i create a function to identify if a number is a prime number or not?

It even has some R code....