Project Euler #10 in Ruby - summation of primes I'd like to have some feedback as to the performances of the algorithm. 

class Sumprime
    attr_accessor :number

    def initialize(number)
        self.number = number
        prime_serie
    end

    def is_prime?(num)
        counter = 2
        root_num = Math.sqrt(num).ceil
            while counter &lt;= root_num
                    if num % counter == 0 &amp;&amp; num != counter
                        return false
                        break
                    else
                        counter += 1
                    end
            end
            return true
    end

    def percentage_prime
        ((prime_serie.size / number.to_f) * 100)
    end


    def prime_serie
        prime_array = [1]
        counter = 2
        while counter &lt; number
            if is_prime?(counter)
                prime_array &lt;&lt; counter
                counter += 1
            end
            counter += 1
        end
        prime_array.inject(:+)
    end
end
Instead of checking whether each number from 2 until n is prime, you could generate all the primes that are less or equal to n using an algorithm like the Sieve of Eratosthenes.

A trivial implementation of the sieve in ruby is:

def sieve(n)
  sieve = []
  root = Math.sqrt(n)
  (3..root).step(2) do |i|
    if !sieve[i]
      (i**2..n).step(i) do |j|
        sieve[j] = true
      end
    end
  end
  [2] + (3..n).step(2).select{ |i| !sieve[i] }
end


Thus, your code could be rewritten as:

class NewSumprime
  attr_accessor :number

  def initialize(number)
    self.number = number
  end

  def sieve(n)
    sieve = []
    root = Math.sqrt(n)
    (3..root).step(2) do |i|
      if !sieve[i]
        (i**2..n).step(i) do |j|
          sieve[j] = true
        end
      end
    end
    [2] + (3..n).step(2).select{ |i| !sieve[i] }
  end

  def prime_serie
    sieve(number).inject(&amp;:+)
  end
end


A simple benchmark on my PC gives:

ts = Time.now.to_f ; Sumprime.new(1000000).prime_serie ; Time.now.to_f - ts 
=&gt; 11.137484788894653
ts = Time.now.to_f ; NewSumprime.new(1000000).prime_serie ; Time.now.to_f - ts
=&gt; 0.493511438369751