title: Program Check Plus Perfect Number
signature: function programCheckPlusPerfectNumber(x) {
test_code: 
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  function convertToString(value) {
      return JSON.stringify(value, function (key, val) {
          if (val instanceof Set) {
              return Array.from(val);
          } return val;});
  }
  
  function validateSolution(actual, expected){
      return convertToString(actual)===convertToString(expected);
  }
  
  function driver(x, expected){
      try{
          if (validateSolution(PLACEHOLDER_FN_NAME(x),expected)){
              return "PASSED";
          }
          return "FAILED";
      } catch (error) {
        return error.name;
      }
      
  }
      
  function main(){
    let result = '';
    result = driver(371, true);
    console.log(`TEST-0...${result}`);
  
    result = driver(9474, true);
    console.log(`TEST-1...${result}`);
  
    result = driver(85, false);
    console.log(`TEST-2...${result}`);
  
    result = driver(35, false);
    console.log(`TEST-3...${result}`);
  
    result = driver(54, false);
    console.log(`TEST-4...${result}`);
  
    result = driver(17, false);
    console.log(`TEST-5...${result}`);
  
    result = driver(97, false);
    console.log(`TEST-6...${result}`);
  
    result = driver(63, false);
    console.log(`TEST-7...${result}`);
  
    result = driver(12, false);
    console.log(`TEST-8...${result}`);
  
    result = driver(43, false);
    console.log(`TEST-9...${result}`);
  
    process.exit(0);
  };
  
  if (require.main === module) {
    main();
  }
source_py: def program_check_plus_perfect_number(x):
      temp = x
      n = 0
      while (x != 0):
          x = (x // 10)
          n = (n + 1)
      x = temp
      sm = 0
      while (x != 0):
          sm = (sm + int(math.pow((x % 10), n)))
          x = (x // 10)
      return (sm == temp)
source_cpp: bool program_check_plus_perfect_number(int x) {
    int temp = x;
    int n = 0;
    while ( x != 0 ) {
      x /= 10;
      n ++;
    }
    x = temp;
    int sum = 0;
    while ( x != 0 ) {
      sum += pow ( x % 10, n );
      x /= 10;
    }
    return ( sum == temp );
  }