title: Find Sum Modulo K First N Natural Number 1
signature: findSumModuloKFirstNNaturalNumber1(n, k) {
test_code: import 'dart:convert';
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  bool validateSolution(int actual, int expected){
      return actual.toString() == expected.toString();
  }
  
  String driver(n, k, int expected){
      try
      {
          if (validateSolution(PLACEHOLDER_FN_NAME(n, k), expected)){
              return "PASSED";
          }
          return "FAILED";
      }catch(exception_object){
          return exception_object.runtimeType.toString();
      }
  }
  
  int main() {
  
      print("TEST-0...${driver(
          40, 90, 
          2600)
      }");
  
      print("TEST-1...${driver(
          46, 64, 
          2530)
      }");
  
      print("TEST-2...${driver(
          97, 20, 
          1074)
      }");
  
      print("TEST-3...${driver(
          63, 1, 
          0)
      }");
  
      print("TEST-4...${driver(
          92, 52, 
          3166)
      }");
  
      print("TEST-5...${driver(
          60, 35, 
          1345)
      }");
  
      print("TEST-6...${driver(
          67, 40, 
          1684)
      }");
  
      print("TEST-7...${driver(
          61, 62, 
          3751)
      }");
  
      print("TEST-8...${driver(
          74, 61, 
          2311)
      }");
  
      print("TEST-9...${driver(
          67, 41, 
          1691)
      }");
  
      return 0;
  }
source_py: def find_sum_modulo_k_first_n_natural_number_1(N, K):
      ans = 0
      y = (N / K)
      x = (N % K)
      ans = ((((K * (K - 1)) / 2) * y) + ((x * (x + 1)) / 2))
      return int(ans)
source_cpp: int find_sum_modulo_k_first_n_natural_number_1(int N, int K) {
    int ans = 0;
    int y = N / K;
    int x = N % K;
    ans = ( K * ( K - 1 ) / 2 ) * y + ( x * ( x + 1 ) ) / 2;
    return ans;
  }