multipri 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2c07465d02cf62d2a904ca35b5f494e0cb6e1a23
4
- data.tar.gz: bd4724912da485d5e9e5c5ecc52f53a7d5f259a6
3
+ metadata.gz: 7531e7f588e05d606a1958b04974816dbb0ddd6d
4
+ data.tar.gz: 920d74b4c5b193e186e2b0e4c43246d6ac101830
5
5
  SHA512:
6
- metadata.gz: 3ac7b859e45f334923dfc7445a07c721578d9b8e435f2b8cc704467f466ef7d1b570bb7b76b6743a22f5fb00a0ddbbb071a52d01be13a44c22a0430ff6612c69
7
- data.tar.gz: 96881fb032858f7e06342240cd1ed25924f170f1fc2485bcda8f26ad902e9621f2d49b07d558265db38b6417ac542a4fcdac81c9236a5cdd18949a54e67de772
6
+ metadata.gz: c4d48ece4f5c96d9369a69ed3cbcf50c22c5c2e80147b9d6307cf57705c715f227ea26b35961a885b3b10143a4d2582bf97ddd92991a3a400353622b3718f8f7
7
+ data.tar.gz: f2e027e7305bf9ab0da17608736531367103702d9c87c604b9215228d956f80e2c6a2f9030fdecd9d5236d0bf8efc92e0453b9b74caf74628ae9bc0dd0521406
Binary file
@@ -0,0 +1,19 @@
1
+ module Multipri
2
+ class Prime
3
+ include Enumerable
4
+
5
+ def initialize(size=10)
6
+ @size = size
7
+ end
8
+
9
+ def each
10
+ return enum_for(:each) unless block_given?
11
+ # Taken from https://rosettacode.org/wiki/Sieve_of_Eratosthenes
12
+ nums = [nil, nil, *2..@size]
13
+ (2..Math.sqrt(@size)).each do |i|
14
+ (i**2..@size).step(i){|m| nums[m] = nil} if nums[i]
15
+ end
16
+ nums.compact.each { |n| yield n }
17
+ end
18
+ end
19
+ end
@@ -32,7 +32,7 @@ module Multipri
32
32
  end
33
33
 
34
34
  def generate
35
- primes = Prime.first(@size)
35
+ primes = Prime.new.first(@size)
36
36
  @row_titles = primes
37
37
  @rows = primes.map do |p|
38
38
  Row.new(p, primes.map { |q| p * q })
@@ -1,3 +1,3 @@
1
1
  module Multipri
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: multipri
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Madis Nõmme
@@ -90,6 +90,7 @@ files:
90
90
  - lib/multipri.rb
91
91
  - lib/multipri/app.rb
92
92
  - lib/multipri/cli_ui.rb
93
+ - lib/multipri/prime.rb
93
94
  - lib/multipri/primes_table.rb
94
95
  - lib/multipri/version.rb
95
96
  - multipri.gemspec