title: Primality Test Set 5Using Lucas Lehmer Series
signature: class Solution {
  
      public Boolean primalityTestSet5UsingLucasLehmerSeries(Integer p) {
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 );
  }
question_info.extension: java
question_info.entry_fn_name: primalityTestSet5UsingLucasLehmerSeries
question_info.entry_cls_name: Solution
question_info.test_list: [{"idx": 0, "outputs": false, "inputs": {"p": 11}}, {"idx": 1, "outputs": false, "inputs": {"p": 27}}, {"idx": 2, "outputs": true, "inputs": {"p": 31}}, {"idx": 3, "outputs": false, "inputs": {"p": 47}}, {"idx": 4, "outputs": true, "inputs": {"p": 3}}, {"idx": 5, "outputs": false, "inputs": {"p": 14}}, {"idx": 6, "outputs": false, "inputs": {"p": 41}}, {"idx": 7, "outputs": false, "inputs": {"p": 72}}, {"idx": 8, "outputs": false, "inputs": {"p": 39}}, {"idx": 9, "outputs": false, "inputs": {"p": 22}}]
question_info.test_code: import static java.util.Map.entry;  
  import java.util.*;
  import java.lang.*;
  // TESTING CODE 
  // ============================================
  class QuestionEvaluator {
      public static String validateSolution(Integer p, Boolean expected){
          try{
              Driver driver = new Driver();
              if (driver.run(p,expected)){
                  return "PASSED";
              }
              return "FAILED";
              
          } catch (Exception exception_obj){
              return exception_obj.getClass().getSimpleName();
          }
  
      }
      public static void main(String[] args) {
          String result;
          result = validateSolution(11, false);
          System.out.println(String.format("%s%s","TEST-0...",result));    
      
          result = validateSolution(27, false);
          System.out.println(String.format("%s%s","TEST-1...",result));    
      
          result = validateSolution(31, true);
          System.out.println(String.format("%s%s","TEST-2...",result));    
      
          result = validateSolution(47, false);
          System.out.println(String.format("%s%s","TEST-3...",result));    
      
          result = validateSolution(3, true);
          System.out.println(String.format("%s%s","TEST-4...",result));    
      
          result = validateSolution(14, false);
          System.out.println(String.format("%s%s","TEST-5...",result));    
      
          result = validateSolution(41, false);
          System.out.println(String.format("%s%s","TEST-6...",result));    
      
          result = validateSolution(72, false);
          System.out.println(String.format("%s%s","TEST-7...",result));    
      
          result = validateSolution(39, false);
          System.out.println(String.format("%s%s","TEST-8...",result));    
      
          result = validateSolution(22, false);
          System.out.println(String.format("%s%s","TEST-9...",result));    
      
      }
  }
  
  class Driver{
      public boolean run(Integer p, Boolean expected){
  
          PLACEHOLDER_CLS_NAME sol = new PLACEHOLDER_CLS_NAME();
          return validateSolution(sol.PLACEHOLDER_FN_NAME(p),expected);
      }
      
      public boolean validateSolution(Boolean actual, Boolean expected){
          return actual.equals(expected);
      }
  }
  
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
question_info.test_case_ids: 0 1 2 3 4 5 6 7 8 9
question_info.commands: java __FILENAME__