Differentiate multiple numbers of 2, 3,4, 5 and 6

0

I'm writing a function in php and depending on the result of my math expression, my code should return the desired option. My problem starts when I find the numbers that are repeated or are multiple of each other. For example, the numbers 12, 18, 15, 25, etc.

To get the multiple numbers of 2, which returns option 2, my code checks if the number lines mod 2 returns 0. I do even pick up option 3. If the number of lines mod 3 returns 0, I get option 3. The problem starts when I have the number of lines equal to 12 and my code should return option 3, but it returns option 2 because 12 mod 2 and 0.

Can anyone help me solve this? I'm not getting my code to differentiate when and 2, 3, 4 5, and 6. $ sliceLines and the number of lines, which can be from 0 to over a thousand. $ numberOfSpecialConsiderations will always be 4.

//******count options*******
function countOptions($sliceLines, $numberOfSpecialConsiderations){
    $options=0;

    $numberOfStudents= (countNumberOfElements('Section') +1); //ok
    $lines=($sliceLines- $numberOfSpecialConsiderations);


        if( $sliceLines%2==0) {
                      $options=2;
                      }
                else
                    if( ($sliceLines%3==0) AND (($sliceLines/4)==3)){
                        $options=3;
                }

                else 
                    if( $lines%4==0) {
                    $options=4;
                }
                else 
                    if( $lines %5==0) {
                    $options=5;
                    }
                    else {
                $options=6;
                }

    return $options;
}
    
asked by anonymous 11.08.2018 / 19:27

0 answers