Created
February 1, 2024 21:56
-
-
Save jarble/f8a9d0f99c106837401bbb9b22b1ecb2 to your computer and use it in GitHub Desktop.
Inverse of factorial function in MiniZinc
This file contains 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
function int:factorial(int:t) = | |
if t = 0 then 1 else t * factorial(t-1) endif; | |
function int: factorial_inverse(int:n, int:factorial) = | |
if factorial == factorial(n) then n else factorial_inverse(n+1,factorial) endif; | |
function int:factorial_inverse(int:n) = | |
factorial_inverse(0,n); | |
int:a = factorial_inverse(720); | |
solve satisfy; | |
output [show(a)]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment