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 +4 -4
- data/docs/table-10x10.png +0 -0
- data/lib/multipri/prime.rb +19 -0
- data/lib/multipri/primes_table.rb +1 -1
- data/lib/multipri/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7531e7f588e05d606a1958b04974816dbb0ddd6d
|
4
|
+
data.tar.gz: 920d74b4c5b193e186e2b0e4c43246d6ac101830
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c4d48ece4f5c96d9369a69ed3cbcf50c22c5c2e80147b9d6307cf57705c715f227ea26b35961a885b3b10143a4d2582bf97ddd92991a3a400353622b3718f8f7
|
7
|
+
data.tar.gz: f2e027e7305bf9ab0da17608736531367103702d9c87c604b9215228d956f80e2c6a2f9030fdecd9d5236d0bf8efc92e0453b9b74caf74628ae9bc0dd0521406
|
data/docs/table-10x10.png
CHANGED
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
|
data/lib/multipri/version.rb
CHANGED
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.
|
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
|