title: Primality Test Set 5Using Lucas Lehmer Series
signature: pub fn primality_test_set_5using_lucas_lehmer_series(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(p: i32, expected: bool)->String{
      if validate_solution(PLACEHOLDER_FN_NAME(p), expected) {
        return "PASSED".to_string();
      };
      return "FAILED".to_string();
  
  }
  
  fn main() {
      println!("TEST-0...{}", driver(
        11, 
        false
      ));
      
      println!("TEST-1...{}", driver(
        27, 
        false
      ));
      
      println!("TEST-2...{}", driver(
        31, 
        true
      ));
      
      println!("TEST-3...{}", driver(
        47, 
        false
      ));
      
      println!("TEST-4...{}", driver(
        3, 
        true
      ));
      
      println!("TEST-5...{}", driver(
        14, 
        false
      ));
      
      println!("TEST-6...{}", driver(
        41, 
        false
      ));
      
      println!("TEST-7...{}", driver(
        72, 
        false
      ));
      
      println!("TEST-8...{}", driver(
        39, 
        false
      ));
      
      println!("TEST-9...{}", driver(
        22, 
        false
      ));
      
  }
source_py: def primality_test_set_5using_lucas_lehmer_series(p):
      checkNumber = ((2 ** p) - 1)
      nextval = (4 % checkNumber)
      for i in range(1, (p - 1)):
          nextval = (((nextval * nextval) - 2) % checkNumber)
      if (nextval == 0):
          return True
      else:
          return False
source_cpp: bool primality_test_set_5using_lucas_lehmer_series(int p) {
    long long checkNumber = pow ( 2, p ) - 1;
    long long nextval = 4 % checkNumber;
    for ( int i = 1;
    i < p - 1;
    i ++ ) nextval = ( nextval * nextval - 2 ) % checkNumber;
    return ( nextval == 0 );
  }