Date created: 07/10/11 19:00:11. Last modified: 08/06/16 22:12:45

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