primeBefore static method

dynamic primeBefore(
  1. int number
)

Find the first prime there is before the number

Implementation

static primeBefore(int number){
  if((number - 1) <= 2){
    number = 2;
  }else{
    number--;
  }
  while(number.isPrime() == false && number > 2){
    number--;
  }
  return number;
}