Implementation of prime function

Complier went wrong. Couldn't test it.