public static int nextSmallerPrime(int n){
  if (n <= 2) {
    return 1;
  }
  if (n == 3) {
    return 2;
  }
  if ((n & 1) == 0) {
    n--;
  }
 else {
    n-=2;
  }
  while (n > 3 & !isPrime(n)) {
    n-=2;
  }
  return n;
}

public static int nextSmallerPrime ( int n ) { if ( n <= 2 ) { return 1 ; } if ( n == 3 ) { return 2 ; } if ( ( n & 1 ) == 0 ) { n -- ; } else { n -= 2 ; } while ( n > 3 & ! isPrime ( n ) ) { n -= 2 ; } return n ; }
returns the largest prime smaller than the given integer
