Numbers to Roman Numbers with php

前端 未结 6 1751
[愿得一人]
[愿得一人] 2020-12-24 14:11

I need to transform ordinary numbers to Roman numerals with php and I have this code:

        

        
6条回答
  •  -上瘾入骨i
    2020-12-24 14:43

    function rome($N){
        $c='IVXLCDM';
        for($a=5,$b=$s='';$N;$b++,$a^=7)
            for($o=$N%$a,$N=$N/$a^0;$o--;$s=$c[$o>2?$b+$N-($N&=-2)+$o=1:$b].$s);
        return $s;
    }
    
    // from polish wiki
    

提交回复
热议问题