Sha256: b68ea67dd7acb20f30a7c10083f47affbaf38718feda57dca1dcd5a5034019bf

Contents?: true

Size: 509 Bytes

Versions: 36

Compression:

Stored size: 509 Bytes

Contents

#!/usr/bin/env ruby
# encoding: utf-8

# You are probably wondering what the smeg is this example all about.
# Check examples/primes.rb, the only point of this file is to compare
# with its RPC implementation.

require "bundler"
Bundler.setup

MAX = 1000

class Fixnum
  def prime?
    ('1' * self) !~ /^1?$|^(11+?)\1+$/
  end
end

class PrimeChecker
  def is_prime?(number)
    number.prime?
  end
end

prime_checker = PrimeChecker.new

(10_000...(10_000 + MAX)).each do |n|
  prime_checker.is_prime?(n)
end

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
amqp-0.9.10 examples/legacy/primes-simple.rb
amqp-0.9.9 examples/legacy/primes-simple.rb
amqp-0.9.8 examples/legacy/primes-simple.rb
amqp-0.9.7 examples/legacy/primes-simple.rb
amqp-0.9.6 examples/legacy/primes-simple.rb
amqp-0.9.5 examples/legacy/primes-simple.rb
amqp-0.9.4 examples/legacy/primes-simple.rb
amqp-0.9.3 examples/legacy/primes-simple.rb
amqp-0.9.2 examples/legacy/primes-simple.rb
amqp-0.9.1 examples/legacy/primes-simple.rb
amqp-0.9.0 examples/legacy/primes-simple.rb
amqp-0.9.0.pre3 examples/legacy/primes-simple.rb
amqp-0.9.0.pre2 examples/legacy/primes-simple.rb
amqp-0.9.0.pre1 examples/legacy/primes-simple.rb
amqp-0.8.4 examples/legacy/primes-simple.rb
amqp-0.8.3 examples/legacy/primes-simple.rb
amqp-0.8.2 examples/legacy/primes-simple.rb
amqp-0.8.1 examples/legacy/primes-simple.rb
amqp-0.8.0 examples/legacy/primes-simple.rb
amqp-0.8.0.rc15 examples/legacy/primes-simple.rb