title: Program Check Plus Perfect Number
signature: program_check_plus_perfect_number <- function(x) {
test_code: 
  
  
  # SOLUTION CODE
  # ============================================
  PLACEHOLDER_CODE_BODY
  
  # TESTING CODE 
  # ============================================
  validate_solution <- function(actual, expected) {
      toString(actual)==toString(expected)
  }
  
  driver <- function(x, expected){
      if (validate_solution(PLACEHOLDER_FN_NAME(x), expected)){
          "PASSED"
      } else{
          "FAILED"
      }
  }
  
  main <- function() {
      cat(sprintf("TEST-0...%s\n",driver(
          371L, 
          TRUE
      )))
  
      cat(sprintf("TEST-1...%s\n",driver(
          9474L, 
          TRUE
      )))
  
      cat(sprintf("TEST-2...%s\n",driver(
          85L, 
          FALSE
      )))
  
      cat(sprintf("TEST-3...%s\n",driver(
          35L, 
          FALSE
      )))
  
      cat(sprintf("TEST-4...%s\n",driver(
          54L, 
          FALSE
      )))
  
      cat(sprintf("TEST-5...%s\n",driver(
          17L, 
          FALSE
      )))
  
      cat(sprintf("TEST-6...%s\n",driver(
          97L, 
          FALSE
      )))
  
      cat(sprintf("TEST-7...%s\n",driver(
          63L, 
          FALSE
      )))
  
      cat(sprintf("TEST-8...%s\n",driver(
          12L, 
          FALSE
      )))
  
      cat(sprintf("TEST-9...%s\n",driver(
          43L, 
          FALSE
      )))
  
  }
  
  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 );
  }