Solved leap in Bash
This commit is contained in:
14
bash/leap/leap.sh
Normal file
14
bash/leap/leap.sh
Normal 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
|
||||
Reference in New Issue
Block a user