title: Find Sum Modulo K First N Natural Number 1
signature: func findSumModuloKFirstNNaturalNumber1(n int, k int) int {
test_code: package main
  
  import (
      "fmt"
      "reflect"
      "math"
      "sort"
  )
  
  // SOLUTION CODE
  // ===================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE
  // ===================================
  func validateSolution(actual int, expected int) bool {
      return reflect.DeepEqual(actual,expected)
  }
  
  func driver(n int, k int, expected int) string {
      if validateSolution(PLACEHOLDER_FN_NAME(n, k),expected) {
              return "PASSED"
      }
      return "FAILED"
  
  }
  
  func main() {
  
      // Use imports to avoid undefined errors
      var _ = reflect.DeepEqual
      _ = math.Abs
      _ = sort.Sort
      result := ""
      result = driver(40, 
  	90, 2600)
      fmt.Printf("TEST-0...%s\n", result)
      
      result = driver(46, 
  	64, 2530)
      fmt.Printf("TEST-1...%s\n", result)
      
      result = driver(97, 
  	20, 1074)
      fmt.Printf("TEST-2...%s\n", result)
      
      result = driver(63, 
  	1, 0)
      fmt.Printf("TEST-3...%s\n", result)
      
      result = driver(92, 
  	52, 3166)
      fmt.Printf("TEST-4...%s\n", result)
      
      result = driver(60, 
  	35, 1345)
      fmt.Printf("TEST-5...%s\n", result)
      
      result = driver(67, 
  	40, 1684)
      fmt.Printf("TEST-6...%s\n", result)
      
      result = driver(61, 
  	62, 3751)
      fmt.Printf("TEST-7...%s\n", result)
      
      result = driver(74, 
  	61, 2311)
      fmt.Printf("TEST-8...%s\n", result)
      
      result = driver(67, 
  	41, 1691)
      fmt.Printf("TEST-9...%s\n", result)
      
          
  }
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;
  }