-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lcm(::Vector{<:Rational})
gives the wrong answer.
#55379
Comments
The problem shows up even for a singleton array: julia> lcm([1//2])
1//1 See the implementation: Line 153 in 40ecf69
(The problem is with the init argument; in this case, init is 1//1 and lcm(1//1, 1//2) is 1//1 .)
Neither
and
What should the methods return when the input array is empty? Currently, julia> gcd(Int[])
0
julia> lcm(Int[])
1 |
For consistency, we should have |
If #55318 lands, I think we could just remove the |
Here is a correction draft, that would make This is not breaking since the Array argument is still undocumented, and |
You could also define |
I get your point, the inversion symmetry between |
Answering this question (what are Therefore, julia> lcm(3,1//0)
3//1 leaning towards
In the end, |
lcm(::Vector{Rational})
gives the wrong answer.
lcm(::Vector{Rational})
gives the wrong answer.lcm(::Vector{<:Rational})
gives the wrong answer.
In the case of |
I don't think it has to throw necessarily, although I'd be fine with that. My preference would be to use the FTA definition aka where by convention
|
The extension of lcm() and gcd() to both Array and Rational was incorrect. The case of the gcd has been corrected in #34417, but not the lcm:
The text was updated successfully, but these errors were encountered: