Created
January 15, 2020 19:08
-
-
Save Leirda01/dcee67478ec2eb0001a6ffc2a53d4956 to your computer and use it in GitHub Desktop.
compte avec des chiffres romain jusqu’à 3999
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
[[ $1 -gt 3999 ]] && echo $1 too big! && exit 1 | |
result="" | |
for i in $(seq $1); do | |
result+="I" | |
result=${result/%IIII/IV} | |
result=${result/%IVI/V} | |
result=${result/%VIV/IX} | |
result=${result/%IXI/X} | |
result=${result/%XXXX/XL} | |
result=${result/%XLX/L} | |
result=${result/%LXL/XC} | |
result=${result/%XCX/C} | |
result=${result/%CCCC/CD} | |
result=${result/%CDC/D} | |
result=${result/%DCD/CM} | |
result=${result/%CMC/M} | |
printf "%4d → %s\n" $i $result | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment