php uses recursive functions to implement number accumulation, recursive accumulation
This article describes the example of php using recursive functions to implement number accumulation. Share it with everyone for your reference. The specific implementation method is as follows:
<?php
function summation ($count) {
if ($count != 0) :
return $count + summation($count-1);
endif;
}
$sum = summation(10);
print "Summation = $sum";
?>
I hope this article will be helpful to everyone’s PHP programming design.
http://www.bkjia.com/PHPjc/968263.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/968263.htmlTechArticlephp uses recursive functions to achieve digital accumulation. Recursive accumulation This article describes how PHP uses recursive functions to achieve digital accumulation. method. Share it with everyone for your reference. Specific implementation method...
Statement: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