Page 603 - ComputerScience_Class_11
P. 603

23              }
                   24              return reversedNum;

                   25          }
                   26
                   27          boolean isPrime(int x)

                   28          {

                   29              if (x <= 1)
                   30              return false;
                   31              for (int i = 2; i <= Math.sqrt(x); i++)

                   32              {
                   33                  if (x % i == 0)

                   34                  {
                   35                      return false;

                   36                  }
                   37              }

                   38              return true;
                   39          }

                   40
                   41          void isEmirp()

                   42          {
                   43              int revNum = reverse(num);

                   44
                   45              if (isPrime(num) && isPrime(revNum) && num != revNum)

                   46              {
                   47                  System.out.println(num + " is an Emirp number.");

                   48              }
                   49              else

                   50              {
                   51                  System.out.println(num + " is not an Emirp number.");
                   52              }

                   53          }

                   54
                   55          public static void main(String[] args)
                   56          {






                                                                                                Internal Assessment  601
   598   599   600   601   602   603   604   605   606   607   608