epitools 0.5.82 → 0.5.83
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 +4 -4
- data/VERSION +1 -1
- data/lib/epitools/core_ext/numbers.rb +8 -2
- data/spec/core_ext_spec.rb +9 -0
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6adabc111d21c1df43a1d1a47eb88239659f3323
|
|
4
|
+
data.tar.gz: e134b34f0489180eebab792bc44da289938c65bd
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7c0049d721edbedf5d39b3ea4288c7c98070f0a6ed369ff0be257b9198aaf406f8dbe34318fabb4042d5b70461267429e105ee1809c1d51a3c16fabe3863f2b5
|
|
7
|
+
data.tar.gz: b1b2ad4b655c76d6cf5fee775b227e5459c0d569a6e812149321ccda5e21573de8c7fed8661c5ef25fd726d234cd6025fbf70bc6807fdcfbcd6fb727753cd73d
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.5.
|
|
1
|
+
0.5.83
|
|
@@ -312,10 +312,16 @@ class Integer
|
|
|
312
312
|
end
|
|
313
313
|
|
|
314
314
|
#
|
|
315
|
-
# Factorial
|
|
315
|
+
# Factorial
|
|
316
316
|
#
|
|
317
317
|
def fact
|
|
318
|
-
|
|
318
|
+
if self < 0
|
|
319
|
+
-(1..-self).reduce(:*)
|
|
320
|
+
elsif self == 0
|
|
321
|
+
1
|
|
322
|
+
else
|
|
323
|
+
(1..self).reduce(:*)
|
|
324
|
+
end
|
|
319
325
|
end
|
|
320
326
|
alias_method :factorial, :fact
|
|
321
327
|
|
data/spec/core_ext_spec.rb
CHANGED
|
@@ -398,6 +398,15 @@ describe Integer do
|
|
|
398
398
|
[3,5,7,11,13,17,23,3628273133].all? { |n| n.should be_prime }
|
|
399
399
|
end
|
|
400
400
|
|
|
401
|
+
it "factorializes" do
|
|
402
|
+
-3.fact.should == -6
|
|
403
|
+
0.fact.should == 1
|
|
404
|
+
1.fact.should == 1
|
|
405
|
+
2.fact.should == 2
|
|
406
|
+
42.fact.should == 1405006117752879898543142606244511569936384000000000
|
|
407
|
+
9.fact.should == 9.factorial
|
|
408
|
+
end
|
|
409
|
+
|
|
401
410
|
end
|
|
402
411
|
|
|
403
412
|
describe Float do
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: epitools
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.5.
|
|
4
|
+
version: 0.5.83
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- epitron
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2015-12-
|
|
11
|
+
date: 2015-12-15 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rspec
|