rubysh_mathematica 0.1.4 → 0.1.5
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.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 347857f1908cc06c22e8be18889a1b8208b35526
|
4
|
+
data.tar.gz: bc53e9bbcb1502b411965cf50071c76bc7ef9872
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 001d8ca19254d2e0f6d5d206b4be2f8a2e5561832d40e06c334f283ab7ef8ca03b1ed0af66d768f7c96756007c99465886bbbed7c02676cc29dd03aa42bd7370
|
7
|
+
data.tar.gz: 221e018213d54dc5fb3c63047bcbd096b8aae39466f3a5dc3b984fc19d9910f1737767d9b80b4480deb8bc5e0daae2166593620887841c8e56b23d9f8ef39711
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# Integer class method overloading.
|
2
|
+
class Integer
|
3
|
+
# Returns the biggest prime factor
|
4
|
+
# https://en.wikipedia.org/wiki/Prime_factor
|
5
|
+
#
|
6
|
+
# By the fundamental theorem of arithmetic,
|
7
|
+
# every integer n > 1 has a unique factorization of prime numbers.
|
8
|
+
#
|
9
|
+
# n = P1 * P2 * P3 * ... * P(M-1) w/ P(i) > 1 and prime.
|
10
|
+
# If we divide n by its smallest prime factor,
|
11
|
+
# the last one will be the biggest.
|
12
|
+
#
|
13
|
+
def biggest_prime_factor
|
14
|
+
number = self
|
15
|
+
while (factor = number.smallest_prime_factor) < number
|
16
|
+
number /= factor
|
17
|
+
end
|
18
|
+
number
|
19
|
+
end
|
20
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubysh_mathematica
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rubysh
|
@@ -72,6 +72,7 @@ files:
|
|
72
72
|
- lib/rubysh_mathematica/Overloads/Integer/Multiples/is_factor_of.rb
|
73
73
|
- lib/rubysh_mathematica/Overloads/Integer/Multiples/is_multiple_of.rb
|
74
74
|
- lib/rubysh_mathematica/Overloads/Integer/Multiples/multiples.rb
|
75
|
+
- lib/rubysh_mathematica/Overloads/Integer/Prime/get_biggest_prime_factor.rb
|
75
76
|
- lib/rubysh_mathematica/Overloads/Integer/Prime/get_smallest_prime_factor.rb
|
76
77
|
- lib/rubysh_mathematica/Overloads/Integer/Prime/is_composite.rb
|
77
78
|
- lib/rubysh_mathematica/Overloads/Integer/Prime/is_prime.rb
|