<?php class Roman
class Roman
{
public $dividorsBelowTen =
[0 => "", 1 => "I", 2 => "II", 3 => "III", 4 => "IV", 5 => "V", 6 => "VI", 7 => "VII", 8 => "VIII", 9 => "IX"];
public $dividorsTen =
[0 => "", 1 => "X", 2 => "XX", 3 => "XXX", 4 => "XL", 5 => "L", 6 => "LX", 7 => "LXX", 8 => "LXXX", 9 => "XC"]; public $dividorsHundreds = [0 => "", 1 => "C", 2 => "CC", 3 => "CCC", 4 => "CD", 5 => "D", 6 => "DC", 7 => "DCC", 8 => "DCCC", 9 => "CM",];
public $dividorsThousands =
[1 => "M", 2 => "MM", 3 => "MMM", 4 => "MMMM"];
public function transform($in)
{
if ($in >= 1000) {
$thousand = (int)($in / 1000);
$hundreds = (int)(($in - $thousand * 1000) / 100);
$tens = (int)(($in - $thousand * 1000 - $hundreds * 100) / 10);
$once = ($in - $thousand * 1000 - $hundreds * 100 - $tens * 10);
return $this->dividorsThousands[$thousand] . $this->dividorsHundreds[$hundreds] . $this->dividorsTen[$tens] . $this->dividorsBelowTen[$once];
} else if ($in >= 100) {
$hundreds = (int)($in / 100);
$tens = (int)(($in - $hundreds * 100) / 10);
$once = ($in - $hundreds * 100 - $tens * 10);
return $this->dividorsHundreds[$hundreds] . $this->dividorsTen[$tens] . $this->dividorsBelowTen[$once];
} else if ($in >= 10) {
$once = $in % 10;
$tens = (int)($in / 10);
return $this->dividorsTen[$tens] . $this->dividorsBelowTen[$once];
} else {
return $this->dividorsBelowTen[$in];
}
}
}
$r = new Roman();
for ($i = 1; $i < 5000; $i++) {
$r->transform($i);
}
- Output for 5.4.0 - 5.4.32
- Parse error: syntax error, unexpected 'class' (T_CLASS), expecting '{' in /in/ROmKX on line 3
Process exited with code 255. - Output for 4.4.2 - 4.4.9, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29
- Parse error: syntax error, unexpected T_CLASS, expecting '{' in /in/ROmKX on line 3
Process exited with code 255. - Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1, 5.0.0 - 5.0.5
- Parse error: parse error, unexpected T_CLASS, expecting '{' in /in/ROmKX on line 3
Process exited with code 255. - Output for 4.3.2 - 4.3.4
- Parse error: parse error, expecting `'{'' in /in/ROmKX on line 3
Process exited with code 255.
preferences:
210.04 ms | 1386 KiB | 123 Q