Home > Backend Development > PHP Tutorial > PHP recursive function to find factorial

PHP recursive function to find factorial

WBOY
Release: 2016-07-25 08:54:06
Original
1651 people have browsed it
  1. function demo($a)
  2. {
  3. if($a > 1)
  4. {
  5. $r=$a*demo($a-1);
  6. }else
  7. {
  8. $r=$a;
  9. }
  10. return $r;
  11. }
  12. $a=6;
  13. echo $a."The value of the factorial".demo($a);
  14. ?>
Copy code

The display result of php recursive function to find factorial: PHP recursive function to find factorial



Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template