Keep Factorial method and add tests to verify precalculated constants#117
Keep Factorial method and add tests to verify precalculated constants#117
Conversation
|
I thinks we should keep it, at least for all the tests and benches, so we are always sure our pre-calculated constants are really factorials. But also we should not use to much computation if it takes too long, only for parts that will take less than 10 seconds, after that we should use some external trusted resources to verify the big factorial numbers, but only if any of them will be calculated longer than 10 seconds. |
|
🤖 AI Work Session Started Starting automated work session at 2026-04-14T14:16:29.883Z The PR has been converted to draft mode while work is in progress. This comment marks the beginning of an AI work session. Please wait for the session to finish, and provide your feedback. |
Adds two tests that independently compute factorial and Catalan numbers using BigInteger arithmetic and verify they match the precalculated constants in Math._factorials and Math._catalans. Computations that exceed 10 seconds are skipped with a note to use external resources (OEIS A000142 for factorials, OEIS A000108 for Catalan numbers). Fixes #59 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
86eefa9 to
c7b9418
Compare
|
Thanks for the feedback! I've updated this PR to:
|
🤖 Solution Draft LogThis log file contains the complete execution trace of the AI solution draft process. 💰 Cost: $0.983591📊 Context and tokens usage:
Total: (49.5K + 2.1M cached) input tokens, 11.1K output tokens, $0.983591 cost 🤖 Models used:
📎 Log file uploaded as Gist (1195KB)Now working session is ended, feel free to review and add any feedback on the solution draft. |
🔄 Auto-restart triggered (iteration 1)Reason: CI failures detected Starting new session to address the issues. Auto-restart-until-mergeable mode is active. Will continue until PR becomes mergeable. |
…add missing newline Replace XML summary comments on private helper methods with regular line comments (matching existing code style in BitTests.cs/SystemTests.cs), and add missing newline at end of file. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
🔄 Auto-restart-until-mergeable Log (iteration 1)This log file contains the complete execution trace of the AI solution draft process. 💰 Cost: $0.683436📊 Context and tokens usage:Claude Sonnet 4.6:
Total: (39.8K + 1.3M cached) input tokens, 7.5K output tokens, $0.653584 cost Claude Haiku 4.5: Total: 20.4K input tokens, 870 / 64K (1%) output tokens, $0.029852 cost 🤖 Models used:
📎 Log file uploaded as Gist (3103KB)Now working session is ended, feel free to review and add any feedback on the solution draft. |
🔄 Auto-restart triggered (iteration 2)Reason: CI failures detected Starting new session to address the issues. Auto-restart-until-mergeable mode is active. Will continue until PR becomes mergeable. |
…talanWithTimeLimit Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
🔄 Auto-restart-until-mergeable Log (iteration 2)This log file contains the complete execution trace of the AI solution draft process. 💰 Cost: $0.371948📊 Context and tokens usage:
Total: (26.4K + 693.3K cached) input tokens, 4.3K output tokens, $0.371948 cost 🤖 Models used:
📎 Log file uploaded as Gist (4766KB)Now working session is ended, feel free to review and add any feedback on the solution draft. |
✅ Ready to mergeThis pull request is now ready to be merged:
Monitored by hive-mind with --auto-restart-until-mergeable flag |
We need to actually do it in our tests, using real http requests to OEIS. |
|
🤖 AI Work Session Started Starting automated work session at 2026-04-14T14:52:44.700Z The PR has been converted to draft mode while work is in progress. This comment marks the beginning of an AI work session. Please wait for the session to finish, and provide your feedback. |
… times out When local BigInteger computation exceeds the 10-second limit, the expected value is now fetched from the authoritative OEIS b-files via real HTTP requests: - Factorials: OEIS A000142 (https://oeis.org/A000142/b000142.txt) - Catalan numbers: OEIS A000108 (https://oeis.org/A000108/b000108.txt) This replaces the previous behaviour of silently skipping those values. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
🤖 Solution Draft LogThis log file contains the complete execution trace of the AI solution draft process. 💰 Cost: $0.590521📊 Context and tokens usage:
Total: (40.0K + 1.1M cached) input tokens, 8.1K output tokens, $0.590521 cost 🤖 Models used:
📎 Log file uploaded as Gist (821KB)Now working session is ended, feel free to review and add any feedback on the solution draft. |
✅ Ready to mergeThis pull request is now ready to be merged:
Monitored by hive-mind with --auto-restart-until-mergeable flag |

Summary
Based on feedback on this PR, the
Factorialmethod should be kept so we can always verify that our precalculated constants are really correct factorials.This PR adds tests that:
_factorialsconstants match the computed valuesC(n) = (2n)! / ((n+1)! * n!)_catalansconstants match the computed valueshttps://oeis.org/A000142/b000142.txt)https://oeis.org/A000108/b000108.txt)In practice, all values for
n ≤ 36(the currentMaximumCatalanIndex) compute locally in under 1ms — but the OEIS fallback ensures correctness even if the range is extended in future.Test Plan
PrecalculatedFactorialsMatchComputedValues— verifies all 21 factorial constants (0! through 20!) match independently computed BigInteger values; falls back to OEIS A000142 via HTTP if computation exceeds 10sPrecalculatedCatalansMatchComputedFactorials— verifies all 37 Catalan constants (C(0) through C(36)) match independently computed BigInteger values; falls back to OEIS A000108 via HTTP if computation exceeds 10sFixes #59
🤖 Generated with Claude Code