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 CHANGED
@@ -1 +1,2 @@
1
- v�����Y=��՛�A��d�E�9�f="�̶���ӓVg�Lz�Y�_����&ɔ�u���0�o��ì@��n�ߛ(W[z�D��D;��|�,��q�����Ҵ-�܏��%�Z�Ő�ZĭEC�tL6��8��C�HJ��+�n�3Z�Uw�[����t��Z�^n!:E&�j7ֹV��-y��d� �eԃ�X��[3��. �2…d��� v�[�G�~�^����mu��|��5_?gER\�s�&�x1%�j�2
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�ߍ��
@@ -1,3 +1,9 @@
1
+ === 1.0.7 /
2
+ * Fixed error in Integer#prime_factors
3
+
4
+ === 1.0.6 /
5
+ * Fixed an error in Integer#prime_factors
6
+
1
7
  === 1.0.5 /
2
8
  * Fixed another error in Integer#is_fibonacci?
3
9
 
@@ -1,6 +1,6 @@
1
1
  # The module that contains all the methods.
2
2
  module Euler
3
- VERSION = "1.0.5"
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 << 2
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 <= max
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
- i += 2
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)
@@ -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
@@ -1,4 +1,4 @@
1
- #!/usr/bin/ruby
1
+ #!/usr/bin/env ruby
2
2
  require 'test/unit/testsuite'
3
3
  require 'tc_integer_methods.rb'
4
- require 'tc_module.rb'
4
+ require 'tc_module.rb'
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.5
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-10-12 00:00:00 -04:00
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.7.0
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.2.0
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