Are you bored?

Are you bored? Let me make you better!

#train_in_the_terminal
#fun_sum

Fun Sum

        // Sum all even element number of number
        $n = (int) 1222;
        $degit = 0;
        $sum = 0;
        while($n>0){
            $degit = (int)$n%10;
            // not allow to put n/=10 here :))
            if((((int)$n /= 10 ) || ($n<10)) && $degit%2){
                continue;
            }
            $sum+=$degit;
        }
        dd($sum);

Train in the terminal





Nhận xét

Bài đăng phổ biến từ blog này

Phân trang- FIFO, LRU, OPT

Chuyển đổi địa chỉ vật lý và địa chỉ ảo trong bộ nhớ chính

Chuyển Ubuntu sang phân vùng mới