title: Triangular Numbers
signature: triangular_numbers <- function(num) {
test_code: 
  
  
  # SOLUTION CODE
  # ============================================
  PLACEHOLDER_CODE_BODY
  
  # TESTING CODE 
  # ============================================
  validate_solution <- function(actual, expected) {
      toString(actual)==toString(expected)
  }
  
  driver <- function(num, expected){
      if (validate_solution(PLACEHOLDER_FN_NAME(num), expected)){
          "PASSED"
      } else{
          "FAILED"
      }
  }
  
  main <- function() {
      cat(sprintf("TEST-0...%s\n",driver(
          97L, 
          FALSE
      )))
  
      cat(sprintf("TEST-1...%s\n",driver(
          97L, 
          FALSE
      )))
  
      cat(sprintf("TEST-2...%s\n",driver(
          32L, 
          FALSE
      )))
  
      cat(sprintf("TEST-3...%s\n",driver(
          40L, 
          FALSE
      )))
  
      cat(sprintf("TEST-4...%s\n",driver(
          18L, 
          FALSE
      )))
  
      cat(sprintf("TEST-5...%s\n",driver(
          14L, 
          FALSE
      )))
  
      cat(sprintf("TEST-6...%s\n",driver(
          90L, 
          FALSE
      )))
  
      cat(sprintf("TEST-7...%s\n",driver(
          39L, 
          FALSE
      )))
  
      cat(sprintf("TEST-8...%s\n",driver(
          1L, 
          TRUE
      )))
  
      cat(sprintf("TEST-9...%s\n",driver(
          57L, 
          FALSE
      )))
  
  }
  
  main()
source_py: def triangular_numbers(num):
      if (num < 0):
          return False
      (sum, n) = (0, 1)
      while (sum <= num):
          sum = (sum + n)
          if (sum == num):
              return True
          n += 1
      return False
source_cpp: bool triangular_numbers(int num) {
    if ( num < 0 ) return false;
    int sum = 0;
    for ( int n = 1;
    sum <= num;
    n ++ ) {
      sum = sum + n;
      if ( sum == num ) return true;
    }
    return false;
  }