title: Count Number Pairs N B N Gcd B B
signature: func countNumberPairsNBNGcdBB(n int) float64 {
test_code: package main
  
  import (
      "fmt"
      "reflect"
      "math"
      "sort"
  )
  
  // SOLUTION CODE
  // ===================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE
  // ===================================
  func validateSolution(actual float64, expected float64) bool {
      return math.Abs(actual - expected) < 1e-09
  }
  
  func driver(n int, expected float64) string {
      if validateSolution(PLACEHOLDER_FN_NAME(n),expected) {
              return "PASSED"
      }
      return "FAILED"
  
  }
  
  func main() {
  
      // Use imports to avoid undefined errors
      var _ = reflect.DeepEqual
      _ = math.Abs
      _ = sort.Sort
      result := ""
      result = driver(17, 58.47239288489289)
      fmt.Printf("TEST-0...%s\n", result)
      
      result = driver(72, 349.9783310569835)
      fmt.Printf("TEST-1...%s\n", result)
      
      result = driver(43, 187.0499406858786)
      fmt.Printf("TEST-2...%s\n", result)
      
      result = driver(55, 252.6486716559348)
      fmt.Printf("TEST-3...%s\n", result)
      
      result = driver(62, 291.1683590456309)
      fmt.Printf("TEST-4...%s\n", result)
      
      result = driver(22, 81.19789150478006)
      fmt.Printf("TEST-5...%s\n", result)
      
      result = driver(17, 58.47239288489289)
      fmt.Printf("TEST-6...%s\n", result)
      
      result = driver(68, 326.67596370158344)
      fmt.Printf("TEST-7...%s\n", result)
      
      result = driver(20, 71.95479314287363)
      fmt.Printf("TEST-8...%s\n", result)
      
      result = driver(29, 114.88796013002468)
      fmt.Printf("TEST-9...%s\n", result)
      
          
  }
source_py: def count_number_pairs_n_b_n_gcd_b_b(n):
      k = n
      imin = 1
      ans = 0
      while (imin <= n):
          imax = (n / k)
          ans += (k * ((imax - imin) + 1))
          imin = (imax + 1)
          k = (n / imin)
      return ans
source_cpp: int count_number_pairs_n_b_n_gcd_b_b(int n) {
    int k = n;
    int imin = 1;
    int ans = 0;
    while ( imin <= n ) {
      int imax = n / k;
      ans += k * ( imax - imin + 1 );
      imin = imax + 1;
      k = n / imin;
    }
    return ans;
  }