primo(1).
primo(2).

primo(X):- primo_auxiliar(X,2).


primo_auxiliar(X,N):- N > sqrt(X).

primo_auxiliar(X,N):-
               N =< sqrt(X),
               M is X mod N,
               M \= 0,
               N1 is N + 1,
               primo_auxiliar(X,N1).


