Class: Prime

Class | Prime
In: | mathn.rb
Parent: | Object

### Methods

each new next succ

### Included Modules

Enumerable

### Public Class methods

new()

[Source]

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

### Public Instance methods

each() {|succ| ...}

[Source]

    # File mathn.rb, line 101
      def each
        loop do
          yield succ
        end
      end

next()

Alias for succ

succ()

[Source]

    # File mathn.rb, line 77
      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]