Skip to content

Instantly share code, notes, and snippets.

@Leirda01
Created January 15, 2020 19:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Leirda01/dcee67478ec2eb0001a6ffc2a53d4956 to your computer and use it in GitHub Desktop.
Save Leirda01/dcee67478ec2eb0001a6ffc2a53d4956 to your computer and use it in GitHub Desktop.
compte avec des chiffres romain jusqu’à 3999
#!/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