 License Public Domain
 Lines 23
##### Related SnortSnort PointSort, C++, Priority Queue Random Developments Project Euler 2 Project Euler 28
##### Permissions Owner: ragecage Group Owner: SnortSnort Viewable by Everyone Editable by All Siafoo Users You are viewing an old version of this snippet. View Latest Version

# Fibonacci problem - Fortran 0

 In Brief This program outputs the sum of all even numbers in the Fibonacci sequence that are smaller than 4 Million
 Language Fortran
# 's
` 1! fibonacci.f95 2! Program to find the sum of all even Fibonacci numbers less than 4 million. 3 4 5program fibonacci 6 7implicit none 8! Define the single and double precision variables. 9integer i,n(0:2000),sum1011n(0) = 112n(1) = 1131415sum=016print*, 'Number=', n(0), ' SUM=', sum17print*, 'Number=', n(1), ' SUM=', sum1819do i=2,20002021n(i) = n(i-1) + n(i-2)2223if(n(i).ge.4e6) then 24exit25end if2627if(mod(n(i),2).eq.0) then 28sum=sum+n(i)29end if3031print*, 'Number=', n(i), ' SUM=', sum3233end do3435print*, 'Fibonacci number now larger than 4 million'3637end program fibonacci`

This program outputs the sum of all even numbers in the Fibonacci sequence that are smaller than 4 Million