-
-
Notifications
You must be signed in to change notification settings - Fork 61
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
Multi factorial #695
Multi factorial #695
Conversation
@@ -169,6 +169,12 @@ fn test_factorial() { | |||
expect_output("-5!", "-120"); | |||
expect_output("-(5!)", "-120"); | |||
expect_output("-(5)!", "-120"); | |||
expect_output("5!!", "15"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we expand at least the double-factorial tests a bit more and include some edge cases, as well as an example for even numbers. And maybe we could write the tests in a way that it's easy to see that we get the desired result. By moving them to a Numbat-source test suite? Something like
assert_eq(7!!, 7 * 5 * 3 * 1)
assert_eq(8!!, 8 * 4 * 2)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, that should be done in fb066f0
Could you confirm me that we cannot write an assert in a function in numbat currently?
I wanted to write a more « procedural » test with a recursive function that assert at each step that the function works on all numbers from 0 to 10 with multiple orders but then I didn’t see how to do it 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can confirm that it isn't currently possible. I wanted to make a function to encapsulate a repeating pattern in the tests I wrote and learned it wasn't possible yet.
There was some talk about the possibility of numbat having macros for such cases, but that's still just an idea.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you very much, this looks great. I'm not concerned about the breaking change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you
Hey, currently numbat doesn't handle multifactorial correctly, see the following screenshot:

This should in fact returns (5 * 3 * 1): https://en.wikipedia.org/wiki/Double_factorial#Generalizations
This PR adds support for all multifactorial, it's a breaking change though since numbat was already accepting the expression.