title: Eulers Criterion Check If Square Root Under Modulo P Exists
signature: func eulersCriterionCheckIfSquareRootUnderModuloPExists(n int, p int) bool {
test_code: package main
  
  import (
      "fmt"
      "reflect"
      "math"
      "sort"
  )
  
  // SOLUTION CODE
  // ===================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE
  // ===================================
  func validateSolution(actual bool, expected bool) bool {
      return reflect.DeepEqual(actual,expected)
  }
  
  func driver(n int, p int, expected bool) 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(71, 
  	78, false)
      fmt.Printf("TEST-0...%s\n", result)
      
      result = driver(85, 
  	75, false)
      fmt.Printf("TEST-1...%s\n", result)
      
      result = driver(4, 
  	35, true)
      fmt.Printf("TEST-2...%s\n", result)
      
      result = driver(20, 
  	99, false)
      fmt.Printf("TEST-3...%s\n", result)
      
      result = driver(71, 
  	29, true)
      fmt.Printf("TEST-4...%s\n", result)
      
      result = driver(72, 
  	88, false)
      fmt.Printf("TEST-5...%s\n", result)
      
      result = driver(36, 
  	54, true)
      fmt.Printf("TEST-6...%s\n", result)
      
      result = driver(95, 
  	52, false)
      fmt.Printf("TEST-7...%s\n", result)
      
      result = driver(83, 
  	33, false)
      fmt.Printf("TEST-8...%s\n", result)
      
      result = driver(72, 
  	13, false)
      fmt.Printf("TEST-9...%s\n", result)
      
          
  }
source_py: def eulers_criterion_check_if_square_root_under_modulo_p_exists(n, p):
      n = (n % p)
      for x in range(2, p, 1):
          if (((x * x) % p) == n):
              return True
      return False
source_cpp: bool eulers_criterion_check_if_square_root_under_modulo_p_exists(int n, int p) {
    n = n % p;
    for ( int x = 2;
    x < p;
    x ++ ) if ( ( x * x ) % p == n ) return true;
    return false;
  }