Factorial function

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ccjob2
Forum Newbie
Posts: 16
Joined: Tue Jun 04, 2002 9:37 am

Factorial function

Post by ccjob2 »

Hi,
I need to produce a math job like:
x=n!/6!(n-6)!
that formula contain factorial symbol (!). It's possible to make a factorial function to produce factorial or is there a php function just usefull ?
Thanks
Carlo
User avatar
Takuma
Forum Regular
Posts: 931
Joined: Sun Aug 04, 2002 10:24 am
Location: UK
Contact:

Post by Takuma »

You probably can make a function yourself...

Code: Select all

<?php
$answer = 1;
$number = 6;
for($i = 1; $i <= $number; $i++) {
  $answer *= $i; 
}
?>
Post Reply