title: Find Sum Modulo K First N Natural Number 1
signature: class Solution {
  
      public Integer findSumModuloKFirstNNaturalNumber1(Integer n, Integer k) {
test_code: import static java.util.Map.entry;  
  import java.util.*;
  import java.lang.*;
  // TESTING CODE 
  // ============================================
  class QuestionEvaluator {
      public static String validateSolution(Integer n, Integer k, Integer expected){
          try{
              Driver driver = new Driver();
              if (driver.run(n, k,expected)){
                  return "PASSED";
              }
              return "FAILED";
              
          } catch (Exception exception_obj){
              return exception_obj.getClass().getSimpleName();
          }
  
      }
      public static void main(String[] args) {
          String result;
          result = validateSolution(40, 90, 2600);
          System.out.println(String.format("%s%s","TEST-0...",result));    
      
          result = validateSolution(46, 64, 2530);
          System.out.println(String.format("%s%s","TEST-1...",result));    
      
          result = validateSolution(97, 20, 1074);
          System.out.println(String.format("%s%s","TEST-2...",result));    
      
          result = validateSolution(63, 1, 0);
          System.out.println(String.format("%s%s","TEST-3...",result));    
      
          result = validateSolution(92, 52, 3166);
          System.out.println(String.format("%s%s","TEST-4...",result));    
      
          result = validateSolution(60, 35, 1345);
          System.out.println(String.format("%s%s","TEST-5...",result));    
      
          result = validateSolution(67, 40, 1684);
          System.out.println(String.format("%s%s","TEST-6...",result));    
      
          result = validateSolution(61, 62, 3751);
          System.out.println(String.format("%s%s","TEST-7...",result));    
      
          result = validateSolution(74, 61, 2311);
          System.out.println(String.format("%s%s","TEST-8...",result));    
      
          result = validateSolution(67, 41, 1691);
          System.out.println(String.format("%s%s","TEST-9...",result));    
      
      }
  }
  
  class Driver{
      public boolean run(Integer n, Integer k, Integer expected){
  
          PLACEHOLDER_CLS_NAME sol = new PLACEHOLDER_CLS_NAME();
          return validateSolution(sol.PLACEHOLDER_FN_NAME(n, k),expected);
      }
      
      public boolean validateSolution(Integer actual, Integer expected){
          return actual.equals(expected);
      }
  }
  
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
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;
  }