Negative numbers can't be primes by definition
- lib/prime.rb (Prime#prime?): negative numbers can't be primes by definition. reported by Ivan Kataitsev. [Bug #7395]
- test/test_prime.rb: add test.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45878 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
add information of incompatibility about Prime.prime? [Bug #7395]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46061 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
#4 [ruby-core:62465] Updated by ayumin (Ayumu AIZAWA) almost 4 years ago
- Status changed from Assigned to Closed
- % Done changed from 0 to 100
#6 [ruby-core:62487] Updated by mame (Yusuke Endoh) almost 4 years ago
- Status changed from Closed to Assigned
Read the rdoc carefully:
Returns true if +self+ is a prime number, false for a composite.
By definition, a composite number can be also a positive integer greater than 1.
1.prime? #=> false
0.prime? #=> false
(-1).prime? #=> false
looks all buggy (or undefined behavior) to me.
If we can change the spec, it would be good to raise an exception, return nil, or at least update the rdoc.
Anyway, the maintainer (Yugui) should treat this, I think.
Yusuke Endoh email@example.com
#7 [ruby-core:62517] Updated by ayumin (Ayumu AIZAWA) almost 4 years ago
Your opinion seems right.
IMHO, I think Rdoc should be updated.
This method should evaluate the number is prime number or not.
It should not refer the number is composite number or not.
We may have to confirm Yugui's intention anyway.
Luckily I'm going to meet her on Wed, so I will ask her about this issue.
I will add information to NEWS, once change was accepted by Yugui.