Skip to content

Instantly share code, notes, and snippets.

@stevenwilkin
Created January 5, 2017 15:00
Show Gist options
  • Save stevenwilkin/20c9a7f3c5e4a554aaebf7690df2d177 to your computer and use it in GitHub Desktop.
Save stevenwilkin/20c9a7f3c5e4a554aaebf7690df2d177 to your computer and use it in GitHub Desktop.

Revisions

  1. stevenwilkin created this gist Jan 5, 2017.
    12 changes: 12 additions & 0 deletions fizz_buzz.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    #!/bin/bash

    set -u

    for i in $(seq 1 20); do
    divisible_by_three=$(expr $i % 3)
    divisible_by_five=$(expr $i % 5)
    [ $divisible_by_three -eq 0 ] && [ $divisible_by_five -eq 0 ] && echo "Fizz Buzz" && continue
    [ $divisible_by_three -eq 0 ] && echo "Fizz" && continue
    [ $divisible_by_five -eq 0 ] && echo "Buzz" && continue
    echo $i
    done