Page 399 - Cs_withBlue_J_C11_Flipbook
P. 399

17          }
                  18          void check()

                  19          {
                  20              if(num == sum_of_factors(1))  // calling recursive method

                  21                  // display
                  22                  System.out.println(num + " is a Perfect Number");

                  23              else
                  24                  System.out.println(num + " is not a Perfect Number");
                  25          }

                  26          public static void main(int x)

                  27          {
                  28              // Object creation and method calling
                  29              Perfect obj = new Perfect(x);

                  30              obj.check();
                  31          }

                  32      }


                 When you execute the preceding program, the Method Call dialog box appears:
















                 The output of the preceding program is as follows:

                 6 is a Perfect Number
























                                                                                                                       397
                                                                                                           Recursion   397
   394   395   396   397   398   399   400   401   402   403   404