Skip to content

Instantly share code, notes, and snippets.

@jessebutryn
Created March 15, 2019 16:19
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 jessebutryn/a03e5197d8da6e702733aae669128945 to your computer and use it in GitHub Desktop.
Save jessebutryn/a03e5197d8da6e702733aae669128945 to your computer and use it in GitHub Desktop.
#!/bin/bash
multiples=()
is_mult () {
local n=$1
local m=$2
if ! (( n % m )); then
return 0
else
return 1
fi
}
for n in {1..999}; do
if is_mult "$n" 3 || is_mult "$n" 5; then
multiples+=("$n")
fi
done
IFS=+ sum="${multiples[*]}"
echo "$sum" | bc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment