Bug 513520

Summary: Double factorial support
Product: [Applications] kcalc Reporter: cirnos
Component: generalAssignee: Evan Teran <evan.teran>
Status: ASSIGNED ---    
Severity: wishlist CC: cirnos, gabriel.barrantes.dev, opentrimx
Priority: NOR    
Version First Reported In: 25.12.0   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description cirnos 2025-12-18 03:55:50 UTC
SUMMARY
KCalc should support double factorials, as it currently calculates them as (x!)! instead.

STEPS TO REPRODUCE
1. Calculate 7!!

OBSERVED RESULT
Result is (7!)!

EXPECTED RESULT
Result is 7!!, or 105

SOFTWARE/OS VERSIONS
Windows: N/A
macOS: N/A
(available in the Info Center app, or by running `kinfo` in a terminal window)
Linux/KDE Plasma: 
KDE Plasma Version: N/A
KDE Frameworks Version: N/A
Qt Version: N/A

ADDITIONAL INFORMATION
None.
Comment 1 ajay 2025-12-19 15:24:29 UTC
Hi! I am a student and new to KDE development. I would like to try implementing this double factorial (!!) feature. I plan to investigate the knumber logic and the parser to see how to handle the double exclamation mark. If I get stuck, I will let you know so someone else can take over.
Comment 2 Gabriel Barrantes 2025-12-19 16:57:58 UTC
(In reply to ajay from comment #1)
> Hi! I am a student and new to KDE development. I would like to try
> implementing this double factorial (!!) feature. I plan to investigate the
> knumber logic and the parser to see how to handle the double exclamation
> mark. If I get stuck, I will let you know so someone else can take over.

Seems that GNU GMP actually implements mpz_2fac_ui, seems that is the function you a looking for, follow/copy any other function implementation (factorial would be ideal) code to implement this new function. Start in the KNumber library.
Comment 3 Bug Janitor Service 2025-12-19 17:22:34 UTC
A possibly relevant merge request was started @ https://invent.kde.org/utilities/kcalc/-/merge_requests/207