3v4l.org

run code in 300+ PHP versions simultaneously
<?php $test = probabilite(array(0.15, 0.1, 0.55, 0.1), array(0,0,3,1,1), 5); echo $test; function combinaison($nombredeupsvoulus, $nombretotal) { return factoriel($nombretotal)/(factoriel($nombredeupsvoulus)*factoriel($nombretotal-$nombredeupsvoulus)); } function factoriel($nombre){ if($nombre==0) { return 1; }else return $nombre*factoriel($nombre-1); } function probabilite($tableaudeProbabilite, $tableauDesUpMinElements, $nombreDeUpsRestants){ $N=$nombreDeUpsRestants;//nombre de up restant $probaFeu=$tableaudeProbabilite[0];//proba d'up en feu $probaBois=$tableaudeProbabilite[1];//proba d'up en bois $probaEau=$tableaudeProbabilite[2];//proba d'up en eau $probaFoudre=$tableaudeProbabilite[3];//proba d'up en foudre. La proba d'up en air se déduit des autres proba. $feu=$tableauDesUpMinElements[0];//nombre de up min désiré en feu $bois=$tableauDesUpMinElements[1];//nombre de up min désiré en bois $eau=$tableauDesUpMinElements[2];//nombre de up min désiré en eau $foudre=$tableauDesUpMinElements[3];//nombre de up min désiré en foudre $air=$tableauDesUpMinElements[4];//nombre de up min désiré en air $x=$feu; $s1=0; while($x<=($N-($bois+$eau+$foudre+$air))) { $y=$bois; $s2=0; while($y<=($N-($x+$eau+$foudre+$air))) { $z=$eau; $s3=0; while($z<=($N-($x+$y+$foudre+$air))) { $t=$foudre; $s4=0; while($t<=($N-($x+$y+$z+$air))) { $s4=$s4+combinaison($t,$N-($x+$y+$z))*pow($probaFoudre,$t)*pow(1-($probaFeu+$probaBois+$probaEau+$probaFoudre),$N-($x+$y+$z+$t)); $t++; } $s3=$s3+combinaison($z,$N-($x+$y))*pow($probaEau,$z)*$s4; $z++; } $s2=$s2+combinaison($y,$N-$x)*pow($probaBois,$y)*$s3; $y++; } $s1=$s1+combinaison($x,$N)*pow($probaFeu,$x)*$s2; $x++; } return $s1; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jo8ac
function name:  (null)
number of ops:  8
compiled vars:  !0 = $test
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   INIT_FCALL_BY_NAME                                       'probabilite'
          1        SEND_VAL_EX                                              <array>
          2        SEND_VAL_EX                                              <array>
          3        SEND_VAL_EX                                              5
          4        DO_FCALL                                      0  $1      
          5        ASSIGN                                                   !0, $1
    3     6        ECHO                                                     !0
   59     7      > RETURN                                                   1

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

End of function combinaison

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

End of function factoriel

Function probabilite:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 122
Branch analysis from position: 122
2 jumps found. (Code = 44) Position 1 = 128, Position 2 = 25
Branch analysis from position: 128
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 103
Branch analysis from position: 103
2 jumps found. (Code = 44) Position 1 = 109, Position 2 = 28
Branch analysis from position: 109
2 jumps found. (Code = 44) Position 1 = 128, Position 2 = 25
Branch analysis from position: 128
Branch analysis from position: 25
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 83
Branch analysis from position: 83
2 jumps found. (Code = 44) Position 1 = 89, Position 2 = 31
Branch analysis from position: 89
2 jumps found. (Code = 44) Position 1 = 109, Position 2 = 28
Branch analysis from position: 109
Branch analysis from position: 28
Branch analysis from position: 31
1 jumps found. (Code = 42) Position 1 = 62
Branch analysis from position: 62
2 jumps found. (Code = 44) Position 1 = 68, Position 2 = 34
Branch analysis from position: 68
2 jumps found. (Code = 44) Position 1 = 89, Position 2 = 31
Branch analysis from position: 89
Branch analysis from position: 31
Branch analysis from position: 34
2 jumps found. (Code = 44) Position 1 = 68, Position 2 = 34
Branch analysis from position: 68
Branch analysis from position: 34
filename:       /in/jo8ac
function name:  probabilite
number of ops:  130
compiled vars:  !0 = $tableaudeProbabilite, !1 = $tableauDesUpMinElements, !2 = $nombreDeUpsRestants, !3 = $N, !4 = $probaFeu, !5 = $probaBois, !6 = $probaEau, !7 = $probaFoudre, !8 = $feu, !9 = $bois, !10 = $eau, !11 = $foudre, !12 = $air, !13 = $x, !14 = $s1, !15 = $y, !16 = $s2, !17 = $z, !18 = $s3, !19 = $t, !20 = $s4
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
   17     3        ASSIGN                                                   !3, !2
   18     4        FETCH_DIM_R                                      ~22     !0, 0
          5        ASSIGN                                                   !4, ~22
   19     6        FETCH_DIM_R                                      ~24     !0, 1
          7        ASSIGN                                                   !5, ~24
   20     8        FETCH_DIM_R                                      ~26     !0, 2
          9        ASSIGN                                                   !6, ~26
   21    10        FETCH_DIM_R                                      ~28     !0, 3
         11        ASSIGN                                                   !7, ~28
   22    12        FETCH_DIM_R                                      ~30     !1, 0
         13        ASSIGN                                                   !8, ~30
   23    14        FETCH_DIM_R                                      ~32     !1, 1
         15        ASSIGN                                                   !9, ~32
   24    16        FETCH_DIM_R                                      ~34     !1, 2
         17        ASSIGN                                                   !10, ~34
   25    18        FETCH_DIM_R                                      ~36     !1, 3
         19        ASSIGN                                                   !11, ~36
   26    20        FETCH_DIM_R                                      ~38     !1, 4
         21        ASSIGN                                                   !12, ~38
   28    22        ASSIGN                                                   !13, !8
   29    23        ASSIGN                                                   !14, 0
   30    24      > JMP                                                      ->122
   32    25    >   ASSIGN                                                   !15, !9
   33    26        ASSIGN                                                   !16, 0
   34    27      > JMP                                                      ->103
   36    28    >   ASSIGN                                                   !17, !10
   37    29        ASSIGN                                                   !18, 0
   38    30      > JMP                                                      ->83
   40    31    >   ASSIGN                                                   !19, !11
   41    32        ASSIGN                                                   !20, 0
   42    33      > JMP                                                      ->62
   44    34    >   INIT_FCALL                                               'combinaison'
         35        SEND_VAR                                                 !19
         36        ADD                                              ~48     !13, !15
         37        ADD                                              ~49     ~48, !17
         38        SUB                                              ~50     !3, ~49
         39        SEND_VAL                                                 ~50
         40        DO_FCALL                                      0  $51     
         41        INIT_FCALL                                               'pow'
         42        SEND_VAR                                                 !7
         43        SEND_VAR                                                 !19
         44        DO_ICALL                                         $52     
         45        MUL                                              ~53     $51, $52
         46        INIT_FCALL                                               'pow'
         47        ADD                                              ~54     !4, !5
         48        ADD                                              ~55     ~54, !6
         49        ADD                                              ~56     ~55, !7
         50        SUB                                              ~57     1, ~56
         51        SEND_VAL                                                 ~57
         52        ADD                                              ~58     !13, !15
         53        ADD                                              ~59     ~58, !17
         54        ADD                                              ~60     ~59, !19
         55        SUB                                              ~61     !3, ~60
         56        SEND_VAL                                                 ~61
         57        DO_ICALL                                         $62     
         58        MUL                                              ~63     $62, ~53
         59        ADD                                              ~64     !20, ~63
         60        ASSIGN                                                   !20, ~64
   45    61        PRE_INC                                                  !19
   42    62    >   ADD                                              ~67     !13, !15
         63        ADD                                              ~68     ~67, !17
         64        ADD                                              ~69     ~68, !12
         65        SUB                                              ~70     !3, ~69
         66        IS_SMALLER_OR_EQUAL                                      !19, ~70
         67      > JMPNZ                                                    ~71, ->34
   47    68    >   INIT_FCALL                                               'combinaison'
         69        SEND_VAR                                                 !17
         70        ADD                                              ~72     !13, !15
         71        SUB                                              ~73     !3, ~72
         72        SEND_VAL                                                 ~73
         73        DO_FCALL                                      0  $74     
         74        INIT_FCALL                                               'pow'
         75        SEND_VAR                                                 !6
         76        SEND_VAR                                                 !17
         77        DO_ICALL                                         $75     
         78        MUL                                              ~76     $74, $75
         79        MUL                                              ~77     !20, ~76
         80        ADD                                              ~78     !18, ~77
         81        ASSIGN                                                   !18, ~78
   48    82        PRE_INC                                                  !17
   38    83    >   ADD                                              ~81     !13, !15
         84        ADD                                              ~82     ~81, !11
         85        ADD                                              ~83     ~82, !12
         86        SUB                                              ~84     !3, ~83
         87        IS_SMALLER_OR_EQUAL                                      !17, ~84
         88      > JMPNZ                                                    ~85, ->31
   50    89    >   INIT_FCALL                                               'combinaison'
         90        SEND_VAR                                                 !15
         91        SUB                                              ~86     !3, !13
         92        SEND_VAL                                                 ~86
         93        DO_FCALL                                      0  $87     
         94        INIT_FCALL                                               'pow'
         95        SEND_VAR                                                 !5
         96        SEND_VAR                                                 !15
         97        DO_ICALL                                         $88     
         98        MUL                                              ~89     $87, $88
         99        MUL                                              ~90     !18, ~89
        100        ADD                                              ~91     !16, ~90
        101        ASSIGN                                                   !16, ~91
   51   102        PRE_INC                                                  !15
   34   103    >   ADD                                              ~94     !13, !10
        104        ADD                                              ~95     ~94, !11
        105        ADD                                              ~96     ~95, !12
        106        SUB                                              ~97     !3, ~96
        107        IS_SMALLER_OR_EQUAL                                      !15, ~97
        108      > JMPNZ                                                    ~98, ->28
   53   109    >   INIT_FCALL                                               'combinaison'
        110        SEND_VAR                                                 !13
        111        SEND_VAR                                                 !3
        112        DO_FCALL                                      0  $99     
        113        INIT_FCALL                                               'pow'
        114        SEND_VAR                                                 !4
        115        SEND_VAR                                                 !13
        116        DO_ICALL                                         $100    
        117        MUL                                              ~101    $99, $100
        118        MUL                                              ~102    !16, ~101
        119        ADD                                              ~103    !14, ~102
        120        ASSIGN                                                   !14, ~103
   55   121        PRE_INC                                                  !13
   30   122    >   ADD                                              ~106    !9, !10
        123        ADD                                              ~107    ~106, !11
        124        ADD                                              ~108    ~107, !12
        125        SUB                                              ~109    !3, ~108
        126        IS_SMALLER_OR_EQUAL                                      !13, ~109
        127      > JMPNZ                                                    ~110, ->25
   58   128    > > RETURN                                                   !14
   59   129*     > RETURN                                                   null

End of function probabilite

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
174.9 ms | 1406 KiB | 19 Q