title: Sum Series 0 6 0 06 0 006 0 0006 N Terms
signature: function sum_series_0_6_0_06_0_006_0_0006_n_terms(n)
source_py: def sum_series_0_6_0_06_0_006_0_0006_n_terms(n):
      return (0.666 * (1 - (1 / pow(10, n))))
source_cpp: float sum_series_0_6_0_06_0_006_0_0006_n_terms(int n) {
    return ( 0.666 ) * ( 1 - 1 / pow ( 10, n ) );
  }
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(1, 0.5994)
      print(string.format("TEST-0...%s",result))
  
      result = driver(2, 0.65934)
      print(string.format("TEST-1...%s",result))
  
      result = driver(3, 0.665334)
      print(string.format("TEST-2...%s",result))
  
      result = driver(4, 0.6659334)
      print(string.format("TEST-3...%s",result))
  
      result = driver(5, 0.6659933400000001)
      print(string.format("TEST-4...%s",result))
  
      result = driver(74, 0.666)
      print(string.format("TEST-5...%s",result))
  
      result = driver(77, 0.666)
      print(string.format("TEST-6...%s",result))
  
      result = driver(67, 0.666)
      print(string.format("TEST-7...%s",result))
  
      result = driver(9, 0.665999999334)
      print(string.format("TEST-8...%s",result))
  
      result = driver(12, 0.665999999999334)
      print(string.format("TEST-9...%s",result))
  
  end
  
  main()
question_info.entry_cls_name: Solution
question_info.test_list: [{"idx": 0, "outputs": 0.5994, "inputs": {"n": 1}}, {"idx": 1, "outputs": 0.65934, "inputs": {"n": 2}}, {"idx": 2, "outputs": 0.665334, "inputs": {"n": 3}}, {"idx": 3, "outputs": 0.6659334, "inputs": {"n": 4}}, {"idx": 4, "outputs": 0.6659933400000001, "inputs": {"n": 5}}, {"idx": 5, "outputs": 0.666, "inputs": {"n": 74}}, {"idx": 6, "outputs": 0.666, "inputs": {"n": 77}}, {"idx": 7, "outputs": 0.666, "inputs": {"n": 67}}, {"idx": 8, "outputs": 0.665999999334, "inputs": {"n": 9}}, {"idx": 9, "outputs": 0.665999999999334, "inputs": {"n": 12}}]
question_info.extension: lua
question_info.entry_fn_name: sum_series_0_6_0_06_0_006_0_0006_n_terms
question_info.test_case_ids: 0 1 2 3 4 5 6 7 8 9
question_info.commands: lua __FILENAME__