Sha256: adf0d89c165252e909ad7da57265b2f324ca292e12e9ed3db587e64361dc39c8

Contents?: true

Size: 366 Bytes

Versions: 300

Compression:

Stored size: 366 Bytes

Contents

#!/bin/bash

function usage() {
	echo "Usage: leap.sh <year>" >&2
	exit 1
}

# check number of params
if  [ "$#" != 1 ]; then
	usage
fi

# check param is an integer
if ! [[ $1 =~ ^[0-9]+$ ]]; then
	usage
fi

if [ $(($1 % 4)) == 0 ] \
	&& [ $(($1 % 100)) != 0 ] \
	|| [ $(($1 % 400)) == 0 ]; then
	echo "This is a leap year."
else
	echo "This is not a leap year."
fi

Version data entries

300 entries across 300 versions & 1 rubygems

Version Path
trackler-2.2.1.82 tracks/bash/exercises/leap/example.sh
trackler-2.2.1.81 tracks/bash/exercises/leap/example.sh
trackler-2.2.1.80 tracks/bash/exercises/leap/example.sh
trackler-2.2.1.79 tracks/bash/exercises/leap/example.sh
trackler-2.2.1.78 tracks/bash/exercises/leap/example.sh
trackler-2.2.1.77 tracks/bash/exercises/leap/example.sh
trackler-2.2.1.76 tracks/bash/exercises/leap/example.sh
trackler-2.2.1.75 tracks/bash/exercises/leap/example.sh
trackler-2.2.1.74 tracks/bash/exercises/leap/example.sh
trackler-2.2.1.73 tracks/bash/exercises/leap/example.sh
trackler-2.2.1.72 tracks/bash/exercises/leap/example.sh
trackler-2.2.1.71 tracks/bash/exercises/leap/example.sh
trackler-2.2.1.70 tracks/bash/exercises/leap/example.sh
trackler-2.2.1.69 tracks/bash/exercises/leap/example.sh
trackler-2.2.1.68 tracks/bash/exercises/leap/example.sh
trackler-2.2.1.67 tracks/bash/exercises/leap/example.sh
trackler-2.2.1.66 tracks/bash/exercises/leap/example.sh
trackler-2.2.1.65 tracks/bash/exercises/leap/example.sh
trackler-2.2.1.64 tracks/bash/exercises/leap/example.sh
trackler-2.2.1.63 tracks/bash/exercises/leap/example.sh