Ruby - Methods - Introduction

  • + 0 comments
      return false if num <= 1
      return true if num == 2 || num == 3
      return false if num.even? || num % 3 == 0
    
      i = 5
      while i * i <= num
        return false if num % i == 0 || num % (i + 2) == 0
        i += 6
      end
    
      true
    end
    ``