Monday, July 16, 2012

Find factorial using PHP

Function to find the factorial of the given value



function factorial($val){
  if($val == 1){
    return 1;
  }
  else {
     return $val*factorial($val-1);
   }
}



0 comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...
Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Maintained by Web Themes