From 119c75f8c3d22b0ea62e1376c08780274e7b87ca Mon Sep 17 00:00:00 2001 From: Stanislav Malyshev Date: Wed, 6 Dec 2000 14:33:36 +0000 Subject: [PATCH] Add example git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@37167 c90b9560-bf6c-de11-be94-00142212c4b1 --- functions/gmp.xml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/functions/gmp.xml b/functions/gmp.xml index 8026db0f99..2e3d8c28df 100644 --- a/functions/gmp.xml +++ b/functions/gmp.xml @@ -33,6 +33,25 @@ every function that expects GMP number. See also gmp_init function. + + + Factorial function using GMP + +<?php +function fact($x) { + if($x <= 1) + return 1; + else + return gmp_mul($x,fact($x-1)); +} + +print gmp_strval(fact(1000))."\n"; +?> + + + This will calculate factiorial of 1000 (pretty big number) + very fast. +