Ruby - Methods - Introduction

Sort by

recency

|

74 Discussions

|

  • + 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
    ``
    
  • + 0 comments
    def prime?(num)
        ((2..num).select {|x| num % x == 0 }).size == 1 ? true : false
    end
    
  • + 0 comments
    def prime?(num)
      return false if num <= 1
      (2..Math.sqrt(num).to_i).none? { |n| num % n == 0 }
    end
    
  • + 0 comments

    From saving counter space, to having an integrated grinder for freshly ground coffee beans, Best Coffee Maker with grinders provide convenience and simplicity for coffee lovers everywhere. In this blog, we will discuss the best single cup coffee makers with grinders, so that you can find the one that’s perfect for you.

  • + 0 comments

    Here is ruby - methods - introduction problem solution - https://www.gyangav.com/2022/10/hackerrank-ruby-methods-introduction-problem-solution.html