Class Prime
In: mathn.rb
Parent: Object

Methods

each   new   next   succ  

Included Modules

Enumerable

Public Class methods

[Source]

# File mathn.rb, line 72
  def initialize
    @seed = 1
    @primes = []
    @counts = []
  end

Public Instance methods

[Source]

# File mathn.rb, line 102
  def each
    loop do
      yield succ
    end
  end
next()

Alias for succ

[Source]

# File mathn.rb, line 78
  def succ
    i = -1
    size = @primes.size
    while i < size
      if i == -1
        @seed += 1
        i += 1
      else
        while @seed > @counts[i]
          @counts[i] += @primes[i]
        end
        if @seed != @counts[i]
          i += 1
        else
          i = -1
        end
      end
    end
    @primes.push @seed
    @counts.push @seed + @seed
    return @seed
  end

[Validate]

ruby-doc.org is a service of James Britt and Happy Camper Studios, a Ruby application development company in Phoenix, AZ.

Documentation content on ruby-doc.org is provided by remarkable members of the Ruby community.

For more information on the Ruby programming language, visit ruby-lang.org.

Want to help improve Ruby's API docs? See Ruby Documentation Guidelines.