1. JAVA, Andreas Kunft


/*

 * ACM Programming Contest

 * Problem:     10235 (Simply Emirp)

 * Status:        Accepted

 * Language:    JAVA

 * Runtime:        0.530

 * Date:        2009-03-25 12:40:39

 * Author:        Andreas Kunft

 */



import java.io.BufferedReader;

import java.io.IOException;

import java.io.InputStreamReader;



public class Main

{

    public static void main(String... args) throws IOException

    {

        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

        for (String line = reader.readLine(); line != null; line = reader.readLine())

        {

            int number = Integer.parseInt(line);

            int reverse = Integer.parseInt(new StringBuilder(line).reverse().toString());



            if (isPrime(number))

            {

                // An emirp is a prime that gives you a different!!!!

                // prime when its digits are reversed

                if (isPrime(reverse) && number != reverse)

                    System.out.println(number + " is emirp.");

                else

                    System.out.println(number + " is prime.");

            }

            else

                System.out.println(number + " is not prime.");

        }

    }



    private static boolean isPrime(int n)

    {

        if (n == 2)

            return true;

        if (n % 2 == 0)

            return false;

        for (int i = 3; i <= Math.sqrt(n); i += 2)

            if (n % i == 0)

                return false;

        return true;

    }

}