index c384af18ee89dee5f0dd16ed166cea97aac90e0d..77f43739a7c1f0a7576c7870fbd0a18ec59ad742 100644 (file)
f
(1 row)
-SELECT 4! AS twenty_four;
- twenty_four
--------------
- 24
-(1 row)
-
-SELECT !!3 AS six;
- six
------
- 6
-(1 row)
-
SELECT 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 AS ten;
ten
-----
index c7fe63d03744432094f86e28532dd928f0ed43e8..b255be7c8520841c3667caf4ddb36a912534ad77 100644 (file)
SELECT lcm(9999 * (10::numeric)^131068 + (10::numeric^131068 - 1), 2); -- overflow
ERROR: value overflows numeric format
+--
+-- Tests for factorial
+--
+SELECT 4!;
+ ?column?
+----------
+ 24
+(1 row)
+
+SELECT !!3;
+ ?column?
+----------
+ 6
+(1 row)
+
+SELECT factorial(15);
+ factorial
+---------------
+ 1307674368000
+(1 row)
+
+SELECT 100000!;
+ERROR: value overflows numeric format
+SELECT 0!;
+ ?column?
+----------
+ 1
+(1 row)
+
+SELECT -4!;
+ ?column?
+----------
+ 1
+(1 row)
+
+SELECT factorial(-4);
+ factorial
+-----------
+ 1
+(1 row)
+
index a9e90a96c4c092eb22770474af75bddc08ca4686..b00c9dea2a6daa2c48daf1440027db33c4d947d6 100644 (file)
@@ -114,10 +114,6 @@ SELECT int2 '2' * int4 '2' = int4 '16' / int2 '4' AS true;
SELECT int4 '1000' < int4 '999' AS false;
-SELECT 4! AS twenty_four;
-
-SELECT !!3 AS six;
-
SELECT 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 AS ten;
SELECT 2 + 2 / 2 AS three;
index 41475a9a245f44d063e57c3a5ad62eb49f2848a0..1332a9cf07a6c0dc6a7ab6df6705672636d2c0e5 100644 (file)
(4232.820::numeric, 132.72000::numeric)) AS v(a, b);
SELECT lcm(9999 * (10::numeric)^131068 + (10::numeric^131068 - 1), 2); -- overflow
+
+--
+-- Tests for factorial
+--
+SELECT 4!;
+SELECT !!3;
+SELECT factorial(15);
+SELECT 100000!;
+SELECT 0!;
+SELECT -4!;
+SELECT factorial(-4);