title: Find Sum Modulo K First N Natural Number 1
signature: function findSumModuloKFirstNNaturalNumber1(n: number, k: number): number {
test_code: 
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  function convertToString(value: any): string{
      return JSON.stringify(value, function (key, val) {
          if (val instanceof Set) {
              return Array.from(val);
          } return val;});
  }
  
  function validateSolution(actual: number, expected: number): boolean {
      return convertToString(actual) === convertToString(expected);
  }
  
  function driver(n: number, k: number, expected:number): string {
      try{
          if (validateSolution(PLACEHOLDER_FN_NAME(n, k),expected)){
              return "PASSED";
          }
          return "FAILED";
      } catch (error) {
        return error.name;
      }
      
  }
      
  function main(){
    let result = '';
    result = driver(40, 90, 2600);
    console.log(`TEST-0...${result}`);
  
    result = driver(46, 64, 2530);
    console.log(`TEST-1...${result}`);
  
    result = driver(97, 20, 1074);
    console.log(`TEST-2...${result}`);
  
    result = driver(63, 1, 0);
    console.log(`TEST-3...${result}`);
  
    result = driver(92, 52, 3166);
    console.log(`TEST-4...${result}`);
  
    result = driver(60, 35, 1345);
    console.log(`TEST-5...${result}`);
  
    result = driver(67, 40, 1684);
    console.log(`TEST-6...${result}`);
  
    result = driver(61, 62, 3751);
    console.log(`TEST-7...${result}`);
  
    result = driver(74, 61, 2311);
    console.log(`TEST-8...${result}`);
  
    result = driver(67, 41, 1691);
    console.log(`TEST-9...${result}`);
  
  };
  
  main();
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;
  }