FUNCTION isprime(k)
  IMPLICIT NONE
  INTEGER, INTENT (in) :: k
  LOGICAL :: isprime

  INTEGER :: i

  isprime = .TRUE.

  DO i=2,k-1
     IF ( MOD(k,i) == 0 ) THEN
        isprime = .FALSE.
        EXIT
     ENDIF
  ENDDO

END FUNCTION isprime

PROGRAM prime
  IMPLICIT NONE

  INTERFACE 
     FUNCTION isprime(k)
       IMPLICIT NONE
       INTEGER, INTENT (in) :: k
       LOGICAL :: isprime
     END FUNCTION isprime
  END INTERFACE

  PRINT *, isprime(89), isprime(261), isprime(1511)

END PROGRAM prime
