Solved leap in Bash

This commit is contained in:
2023-05-23 17:37:01 +02:00
parent bcfff775dc
commit 6e1b4d03ea
7 changed files with 949 additions and 0 deletions

14
bash/leap/leap.sh Normal file
View File

@@ -0,0 +1,14 @@
#!/usr/bin/env bash
year=$1
if [ $# -ne 1 ] || ! [[ $1 =~ ^[0-9]+$ ]]; then
echo "Usage: leap.sh <year>"
exit 1
fi
if (( year % 4 == 0 && year % 100 != 0 )) || (( year % 400 == 0 )); then
echo "true"
else
echo "false"
fi