3v4l.org

run code in 300+ PHP versions simultaneously
<?php $n = (int)$_POST['n']; $r = (int)$_POST['r']; $model = $_POST['model']; function factorial($n) { if($n == 0 or $n == 1) { return 1; } else { return($n * factorial($n-1)); } } // fungsi permutasi perulangan function permutasi_perulangan($n, $r) { return(pow($n, $r)); } // fungsi permutasi tak berulang function permutasi_tak_berulang($n, $r) { return(factorial($n)/factorial($n-$r)); } ?> <html> <head> <title>Fungsi Permutasi dengan PHP</title> </head> <body> <center> <form method="post"> <table cellpadding=5 cellspacing=2 border=1> <tr> <td>Permutasi</td> <td> <select name="model"> <option value="ulang">Permutasi Perulangan</option> <option value="tidak">Permutasi Tak Berulang</option> </select> </td> </tr> <tr> <td>N</td> <td><input type=text name="n" size=5 value=<? echo $n; ?> /></td> </tr> <tr> <td>M</td> <td><input type=text name="r" size=5 value=<? echo $r; ?> /></td> </tr> <tr> <td colspan=2 align=center><input type="submit" value="Permutasi" /></td> </tr> </table> </form> <?php if(isset($n) && isset($r) && isset($model) && $n != 0 && $r != 0) { if($model == "ulang") { echo "<h2>$n<sup>$r</sup> = "; echo permutasi_perulangan($n, $r); echo "</h2>"; } else { echo "<table border=0 cellpadding=0 cellspacing=0>"; echo "<tr><td align=center style=\"border-bottom: solid #000;\"><font size=6>$n!</font></td>"; echo "<td rowspan=2 valign=middle><font size=6>&nbsp; = ". permutasi_tak_berulang($n ,$r) ."</font>"; echo "</tr>"; echo "<tr><td align=center><font size=6>$r !($n - $r)!</font></td></tr></table>"; } } ?> </center> </body> </html>
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 18, Position 2 = 20
Branch analysis from position: 18
2 jumps found. (Code = 46) Position 1 = 21, Position 2 = 23
Branch analysis from position: 21
2 jumps found. (Code = 46) Position 1 = 24, Position 2 = 26
Branch analysis from position: 24
2 jumps found. (Code = 46) Position 1 = 27, Position 2 = 29
Branch analysis from position: 27
2 jumps found. (Code = 43) Position 1 = 30, Position 2 = 66
Branch analysis from position: 30
2 jumps found. (Code = 43) Position 1 = 32, Position 2 = 45
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 66
Branch analysis from position: 66
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 45
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 66
Branch analysis from position: 29
Branch analysis from position: 26
Branch analysis from position: 23
Branch analysis from position: 20
filename:       /in/V0qRW
function name:  (null)
number of ops:  68
compiled vars:  !0 = $n, !1 = $r, !2 = $model
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   FETCH_R                      global              ~3      '_POST'
          1        FETCH_DIM_R                                      ~4      ~3, 'n'
          2        CAST                                          4  ~5      ~4
          3        ASSIGN                                                   !0, ~5
    3     4        FETCH_R                      global              ~7      '_POST'
          5        FETCH_DIM_R                                      ~8      ~7, 'r'
          6        CAST                                          4  ~9      ~8
          7        ASSIGN                                                   !1, ~9
    4     8        FETCH_R                      global              ~11     '_POST'
          9        FETCH_DIM_R                                      ~12     ~11, 'model'
         10        ASSIGN                                                   !2, ~12
   28    11        ECHO                                                     '+%3Chtml%3E%0A%3Chead%3E%0A%3Ctitle%3EFungsi+Permutasi+dengan+PHP%3C%2Ftitle%3E%0A%3C%2Fhead%3E%0A%3Cbody%3E%0A%3Ccenter%3E%0A%3Cform+method%3D%22post%22%3E%0A%3Ctable+cellpadding%3D5+cellspacing%3D2+border%3D1%3E%0A+%3Ctr%3E%0A++%3Ctd%3EPermutasi%3C%2Ftd%3E%0A++%3Ctd%3E%0A+++%3Cselect+name%3D%22model%22%3E%0A++++%3Coption+value%3D%22ulang%22%3EPermutasi+Perulangan%3C%2Foption%3E%0A++++%3Coption+value%3D%22tidak%22%3EPermutasi+Tak+Berulang%3C%2Foption%3E%0A+++%3C%2Fselect%3E%0A++%3C%2Ftd%3E%0A+%3C%2Ftr%3E%0A+%3Ctr%3E%0A++%3Ctd%3EN%3C%2Ftd%3E%0A++%3Ctd%3E%3Cinput+type%3Dtext+name%3D%22n%22+size%3D5+value%3D'
   47    12        ECHO                                                     !0
         13        ECHO                                                     '+%2F%3E%3C%2Ftd%3E%0A+%3C%2Ftr%3E%0A+%3Ctr%3E%0A++%3Ctd%3EM%3C%2Ftd%3E%0A++%3Ctd%3E%3Cinput+type%3Dtext+name%3D%22r%22+size%3D5+value%3D'
   51    14        ECHO                                                     !1
         15        ECHO                                                     '+%2F%3E%3C%2Ftd%3E%0A+%3C%2Ftr%3E%0A+%3Ctr%3E%0A++%3Ctd+colspan%3D2+align%3Dcenter%3E%3Cinput+type%3D%22submit%22+value%3D%22Permutasi%22+%2F%3E%3C%2Ftd%3E%0A+%3C%2Ftr%3E%0A%3C%2Ftable%3E%0A%3C%2Fform%3E%0A+'
   59    16        ISSET_ISEMPTY_CV                                 ~14     !0
         17      > JMPZ_EX                                          ~14     ~14, ->20
         18    >   ISSET_ISEMPTY_CV                                 ~15     !1
         19        BOOL                                             ~14     ~15
         20    > > JMPZ_EX                                          ~14     ~14, ->23
         21    >   ISSET_ISEMPTY_CV                                 ~16     !2
         22        BOOL                                             ~14     ~16
         23    > > JMPZ_EX                                          ~14     ~14, ->26
         24    >   IS_NOT_EQUAL                                     ~17     !0, 0
         25        BOOL                                             ~14     ~17
         26    > > JMPZ_EX                                          ~14     ~14, ->29
         27    >   IS_NOT_EQUAL                                     ~18     !1, 0
         28        BOOL                                             ~14     ~18
         29    > > JMPZ                                                     ~14, ->66
   61    30    >   IS_EQUAL                                                 !2, 'ulang'
         31      > JMPZ                                                     ~19, ->45
   63    32    >   ROPE_INIT                                     5  ~21     '%3Ch2%3E'
         33        ROPE_ADD                                      1  ~21     ~21, !0
         34        ROPE_ADD                                      2  ~21     ~21, '%3Csup%3E'
         35        ROPE_ADD                                      3  ~21     ~21, !1
         36        ROPE_END                                      4  ~20     ~21, '%3C%2Fsup%3E+%3D+'
         37        ECHO                                                     ~20
   64    38        INIT_FCALL                                               'permutasi_perulangan'
         39        SEND_VAR                                                 !0
         40        SEND_VAR                                                 !1
         41        DO_FCALL                                      0  $24     
         42        ECHO                                                     $24
   65    43        ECHO                                                     '%3C%2Fh2%3E'
         44      > JMP                                                      ->66
   69    45    >   ECHO                                                     '%3Ctable+border%3D0+cellpadding%3D0+cellspacing%3D0%3E'
   70    46        ROPE_INIT                                     3  ~26     '%3Ctr%3E%3Ctd+align%3Dcenter+style%3D%22border-bottom%3A+solid+%23000%3B%22%3E%3Cfont+size%3D6%3E'
         47        ROPE_ADD                                      1  ~26     ~26, !0
         48        ROPE_END                                      2  ~25     ~26, '%21%3C%2Ffont%3E%3C%2Ftd%3E'
         49        ECHO                                                     ~25
   71    50        INIT_FCALL                                               'permutasi_tak_berulang'
         51        SEND_VAR                                                 !0
         52        SEND_VAR                                                 !1
         53        DO_FCALL                                      0  $28     
         54        CONCAT                                           ~29     '%3Ctd+rowspan%3D2+valign%3Dmiddle%3E%3Cfont+size%3D6%3E%26nbsp%3B+%3D+', $28
         55        CONCAT                                           ~30     ~29, '%3C%2Ffont%3E'
         56        ECHO                                                     ~30
   72    57        ECHO                                                     '%3C%2Ftr%3E'
   73    58        ROPE_INIT                                     7  ~32     '%3Ctr%3E%3Ctd+align%3Dcenter%3E%3Cfont+size%3D6%3E'
         59        ROPE_ADD                                      1  ~32     ~32, !1
         60        ROPE_ADD                                      2  ~32     ~32, '+%21%28'
         61        ROPE_ADD                                      3  ~32     ~32, !0
         62        ROPE_ADD                                      4  ~32     ~32, '+-+'
         63        ROPE_ADD                                      5  ~32     ~32, !1
         64        ROPE_END                                      6  ~31     ~32, '%29%21%3C%2Ffont%3E%3C%2Ftd%3E%3C%2Ftr%3E%3C%2Ftable%3E'
         65        ECHO                                                     ~31
   77    66    >   ECHO                                                     '%3C%2Fcenter%3E%0A%3C%2Fbody%3E%0A%3C%2Fhtml%3E'
   79    67      > RETURN                                                   1

Function factorial:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 3, Position 2 = 5
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 8
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
filename:       /in/V0qRW
function name:  factorial
number of ops:  15
compiled vars:  !0 = $n
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
    8     1        IS_EQUAL                                         ~1      !0, 0
          2      > JMPNZ_EX                                         ~1      ~1, ->5
          3    >   IS_EQUAL                                         ~2      !0, 1
          4        BOOL                                             ~1      ~2
          5    > > JMPZ                                                     ~1, ->8
   10     6    > > RETURN                                                   1
          7*       JMP                                                      ->14
   14     8    >   INIT_FCALL_BY_NAME                                       'factorial'
          9        SUB                                              ~3      !0, 1
         10        SEND_VAL_EX                                              ~3
         11        DO_FCALL                                      0  $4      
         12        MUL                                              ~5      !0, $4
         13      > RETURN                                                   ~5
   16    14*     > RETURN                                                   null

End of function factorial

Function permutasi_perulangan:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/V0qRW
function name:  permutasi_perulangan
number of ops:  8
compiled vars:  !0 = $n, !1 = $r
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   20     2        INIT_FCALL                                               'pow'
          3        SEND_VAR                                                 !0
          4        SEND_VAR                                                 !1
          5        DO_ICALL                                         $2      
          6      > RETURN                                                   $2
   21     7*     > RETURN                                                   null

End of function permutasi_perulangan

Function permutasi_tak_berulang:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/V0qRW
function name:  permutasi_tak_berulang
number of ops:  12
compiled vars:  !0 = $n, !1 = $r
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   25     2        INIT_FCALL                                               'factorial'
          3        SEND_VAR                                                 !0
          4        DO_FCALL                                      0  $2      
          5        INIT_FCALL                                               'factorial'
          6        SUB                                              ~3      !0, !1
          7        SEND_VAL                                                 ~3
          8        DO_FCALL                                      0  $4      
          9        DIV                                              ~5      $2, $4
         10      > RETURN                                                   ~5
   26    11*     > RETURN                                                   null

End of function permutasi_tak_berulang

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
172.6 ms | 1411 KiB | 19 Q