Repository navigation
The integer functions reject a rational operand and stop at positive orders - #543
Open
enumeratio wants to merge 1 commit into
Open
enumeratio wants to merge 1 commit into
enumeratio wants to merge 1 commit into
Conversation
…, CatalanNumber and IsPerfect accept rational and non-positive operands: NextPrime(7/2) = 5, DivisorSigma(-1, 12) = 7/3, FactorInteger(12/35), IsSquareFree(6/35), CatalanNumber(1/2) = 8/(3π), IsPerfect(-6) = False; add regression tests. Fix cortex-js#542
This was referenced Nov 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #542
NextPrime,DivisorSigma,FactorInteger,IsSquareFree,CatalanNumberandIsPerfectaccept rational and non-positive operands:NextPrime(7/2)is 5 (a non-integer real or rational; the integer forms andNextPrime(-10) = 2are unchanged).DivisorSigma(k, n)fork < 0is the rationalsigma_{-k}(n) / n^{-k}; a huge order stays unevaluated. Typedintegerfork >= 0,rationalotherwise.FactorInteger(p/q)andIsSquareFree(p/q)factor numerator and denominator.CatalanNumbertakes a real: a positive half-integer is exact (8/(3*Pi)), other positive reals go through Gamma under a float or.N().IsPerfect(n)isFalseforn < 1.Existing tests that pin old behavior changed: none. Left alone because of documented rulings:
GCD/LCMof rationals (symbolic underevaluate()),NextPrime(-10).Known limit:
.N()numericizes a rational operand before the signature check, soFactorInteger(12/35).N()andIsSquareFree(6/35).N()are still anincompatible-typeerror (as they were);evaluate()is exact.