title: Primality Test Set 5Using Lucas Lehmer Series
signature: primalityTestSet5UsingLucasLehmerSeries :: Integer -> Bool
  primalityTestSet5UsingLucasLehmerSeries p = 
test_code: import Text.Printf
  import Control.Exception (catch, SomeException)
  import Data.Typeable
  import qualified Data.List as List
  import qualified Data.Map as Map
  import qualified Data.Set as Set
  
  -- SOLUTION CODE
  -- ============================================
  
  PLACEHOLDER_CODE_BODY
  
  -- TESTING CODE 
  -- ============================================
  validateSolution :: Bool -> Bool -> Bool
  validateSolution actual expected = do
      actual == expected
  
  
  driver :: Integer -> Bool -> String
  driver p expected = do
      if (validateSolution (PLACEHOLDER_FN_NAME p) expected)
          then "PASSED"
      else "FAILED"
  
  main = do
      printf "TEST-0...%s\n" (driver (11) (False) )
  
      printf "TEST-1...%s\n" (driver (27) (False) )
  
      printf "TEST-2...%s\n" (driver (31) (True) )
  
      printf "TEST-3...%s\n" (driver (47) (False) )
  
      printf "TEST-4...%s\n" (driver (3) (True) )
  
      printf "TEST-5...%s\n" (driver (14) (False) )
  
      printf "TEST-6...%s\n" (driver (41) (False) )
  
      printf "TEST-7...%s\n" (driver (72) (False) )
  
      printf "TEST-8...%s\n" (driver (39) (False) )
  
      printf "TEST-9...%s\n" (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 );
  }