euler 1.0.5 → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data.tar.gz.sig +2 -1
- data/History.txt +6 -0
- data/lib/euler.rb +7 -6
- data/test/tc_integer_methods.rb +1 -0
- data/test/test_euler.rb +2 -2
- metadata +4 -4
- metadata.gz.sig +0 -0
data.tar.gz.sig
CHANGED
@@ -1 +1,2 @@
|
|
1
|
-
|
1
|
+
�fu]K~��z��
|
2
|
+
�Ы�������6�ɖ��s�� �<�1_�ΣB�y�י{M�B�ʉ^�O�FS)-�\�\B6���k{ ���2�:�e�'8�w��o�����G)�Q��d6C�������/&��X7?k����B!��.��wNzM.j �/�K+���Q���D�Nw{�?�l}s�-�e�?��S�U�z�ߍ��
|
data/History.txt
CHANGED
data/lib/euler.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# The module that contains all the methods.
|
2
2
|
module Euler
|
3
|
-
VERSION = "1.0.
|
3
|
+
VERSION = "1.0.7"
|
4
4
|
extend self
|
5
5
|
attr_reader :primes, :sieve, :fibonaccis
|
6
6
|
# Several methods for the Integer class.
|
@@ -18,22 +18,22 @@ module Euler
|
|
18
18
|
def prime_factors
|
19
19
|
return [self] if self.prime?
|
20
20
|
current, to_factor, factors, max = 2, self, [], 0
|
21
|
-
# current is the value currently being tested to_factor is the value
|
22
|
-
# being factored (slowly moves to a prime value) factors is the array of
|
21
|
+
# current is the value currently being tested. to_factor is the value
|
22
|
+
# being factored (slowly moves to a prime value). factors is the array of
|
23
23
|
# prime factors max is the maximum value of any factor set after the
|
24
24
|
# next loop
|
25
25
|
while to_factor % current == 0
|
26
|
-
factors <<
|
26
|
+
factors << current
|
27
27
|
to_factor /= current
|
28
28
|
end
|
29
29
|
current += 1
|
30
30
|
max = Math.sqrt(to_factor).to_i + 1
|
31
|
-
while to_factor
|
31
|
+
while to_factor >= max
|
32
32
|
if to_factor % current == 0
|
33
33
|
factors << current
|
34
34
|
to_factor /= current
|
35
35
|
else
|
36
|
-
|
36
|
+
current += 2
|
37
37
|
end
|
38
38
|
end
|
39
39
|
factors << to_factor if to_factor > 1
|
@@ -113,6 +113,7 @@ module Euler
|
|
113
113
|
end
|
114
114
|
end
|
115
115
|
|
116
|
+
|
116
117
|
# A basic prime sieve. Sets Euler.sieve to an array of boolean values that
|
117
118
|
# indicate if that index if prime or not.
|
118
119
|
# Euler.generate_sieve(50)
|
data/test/tc_integer_methods.rb
CHANGED
@@ -12,6 +12,7 @@ class TestIntegerMethods < Test::Unit::TestCase
|
|
12
12
|
def test_prime_factors
|
13
13
|
assert_equal([2, 5], 10.prime_factors, "10 factors into 2 and 5.")
|
14
14
|
assert_equal([2, 2, 5], 20.prime_factors, "20 factors into 2, 2, and 5.")
|
15
|
+
assert_equal([2, 2, 7, 23], 644.prime_factors, "644 factors into 2, 2, 7, and 23.")
|
15
16
|
end
|
16
17
|
|
17
18
|
def test_primality
|
data/test/test_euler.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: euler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Skalnik
|
@@ -30,7 +30,7 @@ cert_chain:
|
|
30
30
|
jjVX87g40jCN9NIGt+c=
|
31
31
|
-----END CERTIFICATE-----
|
32
32
|
|
33
|
-
date: 2008-
|
33
|
+
date: 2008-12-16 00:00:00 -05:00
|
34
34
|
default_executable:
|
35
35
|
dependencies:
|
36
36
|
- !ruby/object:Gem::Dependency
|
@@ -41,7 +41,7 @@ dependencies:
|
|
41
41
|
requirements:
|
42
42
|
- - ">="
|
43
43
|
- !ruby/object:Gem::Version
|
44
|
-
version: 1.
|
44
|
+
version: 1.8.2
|
45
45
|
version:
|
46
46
|
description: A gem that provides a small library to help in removing the repetativeness of solving Project Euler problems.
|
47
47
|
email:
|
@@ -86,7 +86,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
86
86
|
requirements: []
|
87
87
|
|
88
88
|
rubyforge_project: euler
|
89
|
-
rubygems_version: 1.
|
89
|
+
rubygems_version: 1.3.1
|
90
90
|
signing_key:
|
91
91
|
specification_version: 2
|
92
92
|
summary: A small library to help solve Projet Euler problems.
|
metadata.gz.sig
CHANGED
Binary file
|