Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $input = readline();
- function decimal_roman($num) {
- $output = "";
- $roman_value = array("M"=>1000,
- "CM"=>900,
- "D"=>500,
- "CD"=>400,
- "C"=>100,
- "XC"=>90,
- "L"=>50,
- "LX"=>40,
- "X"=>10,
- "IX"=>9,
- "V"=>5,
- "IV"=>4,
- "I"=>1
- );
- foreach ($roman_value as $key => $value) {
- while($num>=$value) {
- $output .= $key;
- $num -= $value;
- }
- }
- return $output;
- }
- echo decimal_roman($input);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement