checking if a number is divisible by 6 PHP

前端 未结 11 1718
不思量自难忘°
不思量自难忘° 2020-12-13 02:15

I want to check if a number is divisible by 6 and if not I need to increase it until it becomes divisible.

how can I do that ?

11条回答
  •  臣服心动
    2020-12-13 02:38

    Simply run a while loop that will continue to loop (and increase the number) until the number is divisible by 6.

    while ($number % 6 != 0) {
        $number++;
    }
    

提交回复
热议问题