title: Divisibility By 7
signature: function divisibilityBy7(num: number): boolean {
test_code: 
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  function convertToString(value: any): string{
      return JSON.stringify(value, function (key, val) {
          if (val instanceof Set) {
              return Array.from(val);
          } return val;});
  }
  
  function validateSolution(actual: boolean, expected: boolean): boolean {
      return convertToString(actual) === convertToString(expected);
  }
  
  function driver(num: number, expected:boolean): string {
      try{
          if (validateSolution(PLACEHOLDER_FN_NAME(num),expected)){
              return "PASSED";
          }
          return "FAILED";
      } catch (error) {
        return error.name;
      }
      
  }
      
  function main(){
    let result = '';
    result = driver(0, true);
    console.log(`TEST-0...${result}`);
  
    result = driver(-21, false);
    console.log(`TEST-1...${result}`);
  
    result = driver(7, true);
    console.log(`TEST-2...${result}`);
  
    result = driver(63, false);
    console.log(`TEST-3...${result}`);
  
    result = driver(84, false);
    console.log(`TEST-4...${result}`);
  
    result = driver(73, false);
    console.log(`TEST-5...${result}`);
  
    result = driver(81, false);
    console.log(`TEST-6...${result}`);
  
    result = driver(-10, false);
    console.log(`TEST-7...${result}`);
  
    result = driver(47, false);
    console.log(`TEST-8...${result}`);
  
    result = driver(23, false);
    console.log(`TEST-9...${result}`);
  
  };
  
  main();
source_py: def divisibility_by_7(num):
      if (num < 0):
          return divisibility_by_7((- num))
      if ((num == 0) or (num == 7)):
          return True
      if (num < 10):
          return False
      return divisibility_by_7(((num / 10) - (2 * (num - ((num / 10) * 10)))))
source_cpp: int divisibility_by_7(int num) {
    if ( num < 0 ) return divisibility_by_7 ( - num );
    if ( num == 0 || num == 7 ) return 1;
    if ( num < 10 ) return 0;
    return divisibility_by_7 ( num / 10 - 2 * ( num - num / 10 * 10 ) );
  }