อ่านๆ pantip แล้วไปเจอกระทู้ถามว่า "โค้ด Factorial ภาษา php ใครสามารถทำได้บ้างง" ไหนๆก็ลองเขียนจนออกมาแล้วเก็บไว้เตือนความทรงจำว่าครั้งนึงก็เคยเขียน php
- <php?
- echo '<table style="width:100%" >
- <tr align="center">
- <td>round</td>
- <td>number</td>
- <td>factorial</td>
- <td>parameter</td>
- <td align="left">display</td>
- </tr>';
- $round;
- $number=6;
- $param = $number-1;
- $factorStr = '6';
- for($round = 1;$round<$number;$round++)
- {
- $factorStr=$factorStr.'*'.$param;
- echo '<tr align="center">
- <td>'.$round.'</td>
- <td>'.($number-$round+1).'</td>
- <td>'.($number-$round+1).'-1</td>
- <td>'.$param.'</td>
- <td align="left">Factorial is '.$factorStr.'</td>
- </tr>';
- $param--;
- }
- ?>
