title: Finding Power Prime Number P N
signature: func findingPowerPrimeNumberPN(n int, p 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, p int, expected float64) string {
      if validateSolution(PLACEHOLDER_FN_NAME(n, p),expected) {
              return "PASSED"
      }
      return "FAILED"
  
  }
  
  func main() {
  
      // Use imports to avoid undefined errors
      var _ = reflect.DeepEqual
      _ = math.Abs
      _ = sort.Sort
      result := ""
      result = driver(49, 
  	30, 1.6333333333333333)
      fmt.Printf("TEST-0...%s\n", result)
      
      result = driver(80, 
  	25, 3.2)
      fmt.Printf("TEST-1...%s\n", result)
      
      result = driver(10, 
  	9, 1.1111111111111112)
      fmt.Printf("TEST-2...%s\n", result)
      
      result = driver(81, 
  	57, 1.4210526315789473)
      fmt.Printf("TEST-3...%s\n", result)
      
      result = driver(11, 
  	4, 2.75)
      fmt.Printf("TEST-4...%s\n", result)
      
      result = driver(45, 
  	34, 1.3235294117647058)
      fmt.Printf("TEST-5...%s\n", result)
      
      result = driver(86, 
  	90, 0.0)
      fmt.Printf("TEST-6...%s\n", result)
      
      result = driver(27, 
  	78, 0.0)
      fmt.Printf("TEST-7...%s\n", result)
      
      result = driver(80, 
  	60, 1.3333333333333333)
      fmt.Printf("TEST-8...%s\n", result)
      
      result = driver(97, 
  	31, 3.129032258064516)
      fmt.Printf("TEST-9...%s\n", result)
      
          
  }
source_py: def finding_power_prime_number_p_n(n, p):
      ans = 0
      temp = p
      while (temp <= n):
          ans += (n / temp)
          temp = (temp * p)
      return ans
source_cpp: int finding_power_prime_number_p_n(int n, int p) {
    int ans = 0;
    int temp = p;
    while ( temp <= n ) {
      ans += n / temp;
      temp = temp * p;
    }
    return ans;
  }