From 8110f062bd0f9773cb01a164aefbd476afdf909d Mon Sep 17 00:00:00 2001 From: fabiobarkoski Date: Sun, 28 Jul 2024 23:57:00 -0300 Subject: [PATCH] more operations --- arithmetics.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/arithmetics.ts b/arithmetics.ts index 6197973..6fe4aca 100644 --- a/arithmetics.ts +++ b/arithmetics.ts @@ -30,4 +30,22 @@ type Fib = N extends _0 ? N : Add>, Fib>>; +type Factorial = N extends _0 + ? _1 + : Multiply>> + +type Modulo = B extends _0 + ? _0 + : ModHelper, B> + +type ModHelper = Sub extends _0 + ? A extends B + ? Modulo + : A + : Modulo + +type IsEven = Modulo extends _0 + ? true + : false + type Result = Add<_2, _2>;