Date created: Sunday, July 10, 2011 7:00:11 PM. Last modified: Saturday, August 6, 2016 10:12:45 PM

Problem 1

#!/bin/bash
# Project Euler - Problem 1 - Revised

target=999
sum=0
for ((i=1;i<=$target;i++))
do
       if [ `expr $i % 3` -eq 0 ] || [ `expr $i % 5` -eq 0 ]
       then
               sum=$(($sum + $i))
       fi
done
echo $sum

Previous page: Problems
Next page: Problem 2