Date created: 07/10/11 19:05:48. Last modified: 12/13/12 11:41:20

Problem 2

#!/bin/bash
# Project Euler - Problem 2

last=0
this=1
total=0

while (($this<4000000))
do
f=`expr $this + $last`
if [ `expr $f % 2` == 0 ]
then
total=`expr $total + $f`
fi
last=$this
this=$f
done
echo $total

Previous page: Problem 1
Next page: Problem 3