title: Count Number Pairs N B N Gcd B B
signature: function count_number_pairs_n_b_n_gcd_b_b(n)
source_py: def count_number_pairs_n_b_n_gcd_b_b(n):
      k = n
      imin = 1
      ans = 0
      while (imin <= n):
          imax = (n / k)
          ans += (k * ((imax - imin) + 1))
          imin = (imax + 1)
          k = (n / imin)
      return ans
source_cpp: int count_number_pairs_n_b_n_gcd_b_b(int n) {
    int k = n;
    int imin = 1;
    int ans = 0;
    while ( imin <= n ) {
      int imax = n / k;
      ans += k * ( imax - imin + 1 );
      imin = imax + 1;
      k = n / imin;
    }
    return ans;
  }
question_info.test_code: 
  
  -- SOLUTION CODE
  -- ============================================
  PLACEHOLDER_CODE_BODY
  
  -- TESTING CODE 
  -- ============================================
  function isCorrect(actual, expected)
      if type(expected) ~= type(actual) then
          return false
      end
      
      if type(expected) == 'table' then
          for k,v_expected in pairs(expected) do
              
              if actual[k] == nil then
                  return false
              end
              local v_actual = actual[k]
              if not isCorrect(v_actual, v_expected) then
                  return false
              end
              actual[k]=nil
          end
      
          if next(actual) then 
              return false
          end
          return true
      else
          return actual == expected
      end
  end
  
  function validateSolution(actual, expected)
      return math.abs(actual - expected) < 1e-09
  end
  
  function driver(n, expected)
      local exec_result;
      local status, error_msg = pcall(function () 
          exec_result=PLACEHOLDER_FN_NAME(n) 
      end)
      if status then
          if validateSolution(exec_result,expected) then
              return "PASSED"
          end
          return "FAILED"
      else
          return string.format("ERROR=%s",string.gsub(error_msg,".*:[%d]+: ",""))
      end
  end
      
  function main()
      result = driver(17, 58.47239288489289)
      print(string.format("TEST-0...%s",result))
  
      result = driver(72, 349.9783310569835)
      print(string.format("TEST-1...%s",result))
  
      result = driver(43, 187.0499406858786)
      print(string.format("TEST-2...%s",result))
  
      result = driver(55, 252.6486716559348)
      print(string.format("TEST-3...%s",result))
  
      result = driver(62, 291.1683590456309)
      print(string.format("TEST-4...%s",result))
  
      result = driver(22, 81.19789150478006)
      print(string.format("TEST-5...%s",result))
  
      result = driver(17, 58.47239288489289)
      print(string.format("TEST-6...%s",result))
  
      result = driver(68, 326.67596370158344)
      print(string.format("TEST-7...%s",result))
  
      result = driver(20, 71.95479314287363)
      print(string.format("TEST-8...%s",result))
  
      result = driver(29, 114.88796013002468)
      print(string.format("TEST-9...%s",result))
  
  end
  
  main()
question_info.entry_cls_name: Solution
question_info.test_list: [{"idx": 0, "outputs": 58.47239288489289, "inputs": {"n": 17}}, {"idx": 1, "outputs": 349.9783310569835, "inputs": {"n": 72}}, {"idx": 2, "outputs": 187.0499406858786, "inputs": {"n": 43}}, {"idx": 3, "outputs": 252.6486716559348, "inputs": {"n": 55}}, {"idx": 4, "outputs": 291.1683590456309, "inputs": {"n": 62}}, {"idx": 5, "outputs": 81.19789150478006, "inputs": {"n": 22}}, {"idx": 6, "outputs": 58.47239288489289, "inputs": {"n": 17}}, {"idx": 7, "outputs": 326.67596370158344, "inputs": {"n": 68}}, {"idx": 8, "outputs": 71.95479314287363, "inputs": {"n": 20}}, {"idx": 9, "outputs": 114.88796013002468, "inputs": {"n": 29}}]
question_info.extension: lua
question_info.entry_fn_name: count_number_pairs_n_b_n_gcd_b_b
question_info.test_case_ids: 0 1 2 3 4 5 6 7 8 9
question_info.commands: lua __FILENAME__