title: Eulers Criterion Check If Square Root Under Modulo P Exists
signature: pub fn eulers_criterion_check_if_square_root_under_modulo_p_exists(n: i32, p: i32) -> bool {
test_code: use std::collections::HashMap;
  use std::collections::HashSet;
  use std::cmp::*;
  use std::collections::*;
  use std::fmt::*; 
  
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  pub fn validate_solution(actual: bool, expected: bool)->bool{
  return actual==expected
  }
  pub fn driver(n: i32, p: i32, expected: bool)->String{
      if validate_solution(PLACEHOLDER_FN_NAME(n, p), expected) {
        return "PASSED".to_string();
      };
      return "FAILED".to_string();
  
  }
  
  fn main() {
      println!("TEST-0...{}", driver(
        71, 78, 
        false
      ));
      
      println!("TEST-1...{}", driver(
        85, 75, 
        false
      ));
      
      println!("TEST-2...{}", driver(
        4, 35, 
        true
      ));
      
      println!("TEST-3...{}", driver(
        20, 99, 
        false
      ));
      
      println!("TEST-4...{}", driver(
        71, 29, 
        true
      ));
      
      println!("TEST-5...{}", driver(
        72, 88, 
        false
      ));
      
      println!("TEST-6...{}", driver(
        36, 54, 
        true
      ));
      
      println!("TEST-7...{}", driver(
        95, 52, 
        false
      ));
      
      println!("TEST-8...{}", driver(
        83, 33, 
        false
      ));
      
      println!("TEST-9...{}", driver(
        72, 13, 
        false
      ));
      
  }
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;
  }