Date created: Sunday, July 10, 2011 7:05:48 PM. Last modified: Thursday, December 13, 2012 11:41:20 AM

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