Return to Snippet

Revision: 40745
at February 7, 2011 03:08 by 13tazer31


Initial Code
fibonacci(_,Current,End,0) :-
	Current > End.
fibonacci(Previous, Current, End, Total) :-
	divisible(Current, 2),
	Next is Current + Previous,
	fibonacci(Current, Next, End, Sum),
	Total is Sum + Current, !.
fibonacci(Previous, Current, End, Total) :-
	Next is Current + Previous,
	fibonacci(Current, Next, End, Total).

divisible(Number, 0) :-
	write('Error: division by 0').		
divisible(Number, Divisor) :-
	Number mod Divisor =:= 0.

Initial URL
http://13tazer31.wordpress.com/2011/02/06/project-euler-problem-2/

Initial Description

                                

Initial Title
Project Euler - Problem 2

Initial Tags
math

Initial Language
Prolog