title: Triangular Numbers 1
signature: class Solution {
  
      public Boolean triangularNumbers1(Integer num) {
test_code: import static java.util.Map.entry;  
  import java.util.*;
  import java.lang.*;
  // TESTING CODE 
  // ============================================
  class QuestionEvaluator {
      public static String validateSolution(Integer num, Boolean expected){
          try{
              Driver driver = new Driver();
              if (driver.run(num,expected)){
                  return "PASSED";
              }
              return "FAILED";
              
          } catch (Exception exception_obj){
              return exception_obj.getClass().getSimpleName();
          }
  
      }
      public static void main(String[] args) {
          String result;
          result = validateSolution(1, true);
          System.out.println(String.format("%s%s","TEST-0...",result));    
      
          result = validateSolution(3, true);
          System.out.println(String.format("%s%s","TEST-1...",result));    
      
          result = validateSolution(6, true);
          System.out.println(String.format("%s%s","TEST-2...",result));    
      
          result = validateSolution(10, true);
          System.out.println(String.format("%s%s","TEST-3...",result));    
      
          result = validateSolution(55, true);
          System.out.println(String.format("%s%s","TEST-4...",result));    
      
          result = validateSolution(48, false);
          System.out.println(String.format("%s%s","TEST-5...",result));    
      
          result = validateSolution(63, false);
          System.out.println(String.format("%s%s","TEST-6...",result));    
      
          result = validateSolution(72, false);
          System.out.println(String.format("%s%s","TEST-7...",result));    
      
          result = validateSolution(16, false);
          System.out.println(String.format("%s%s","TEST-8...",result));    
      
          result = validateSolution(85, false);
          System.out.println(String.format("%s%s","TEST-9...",result));    
      
      }
  }
  
  class Driver{
      public boolean run(Integer num, Boolean expected){
  
          PLACEHOLDER_CLS_NAME sol = new PLACEHOLDER_CLS_NAME();
          return validateSolution(sol.PLACEHOLDER_FN_NAME(num),expected);
      }
      
      public boolean validateSolution(Boolean actual, Boolean expected){
          return actual.equals(expected);
      }
  }
  
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
source_py: def triangular_numbers_1(num):
      if (num < 0):
          return False
      c = ((- 2) * num)
      (b, a) = (1, 1)
      d = ((b * b) - ((4 * a) * c))
      if (d < 0):
          return False
      root1 = (((- b) + math.sqrt(d)) / (2 * a))
      root2 = (((- b) - math.sqrt(d)) / (2 * a))
      if ((root1 > 0) and (math.floor(root1) == root1)):
          return True
      if ((root2 > 0) and (math.floor(root2) == root2)):
          return True
      return False
source_cpp: bool triangular_numbers_1(int num) {
    if ( num < 0 ) return false;
    int c = ( - 2 * num );
    int b = 1, a = 1;
    int d = ( b * b ) - ( 4 * a * c );
    if ( d < 0 ) return false;
    float root1 = ( - b + sqrt ( d ) ) / ( 2 * a );
    float root2 = ( - b - sqrt ( d ) ) / ( 2 * a );
    if ( root1 > 0 && floor ( root1 ) == root1 ) return true;
    if ( root2 > 0 && floor ( root2 ) == root2 ) return true;
    return false;
  }