euler-02-nonterm.pl

loading
details
attribute value
description
owner Johannes Waldmann
uploaded 2017-08-17 03:45:08.0
disk size 658 Bytes
downloadable true
type
attribute value
name no_type
processor id 1
description this is the default benchmark type for rejected benchmarks and benchmarks that are not associated with a type.
owning community none
loading contents
%Source: Implementation of problems 1 through 4 from www.projecteuler.net
%query:euler2(i,o).
euler2(Bound, Result) :- sumEvenFib(0,0,Bound,Result).

sumEvenFib(Fib1, Fib2, Bound, Result) :- nextFib(Fib1, Fib2, NextFib), NextFib > Bound, Result is 0.
sumEvenFib(Fib1, Fib2, Bound, Result) :- nextFib(Fib1, Fib2, NextFib), NextFib =< Bound, NextFib mod 2 =:= 0, sumEvenFib(Fib2, NextFib, Bound, RecursiveResult), Result is RecursiveResult + NextFib.
sumEvenFib(Fib1, Fib2, Bound, Result) :- nextFib(Fib1, Fib2, NextFib), NextFib =< Bound, NextFib mod 2 =\= 0, sumEvenFib(Fib2, NextFib, Bound, Result).

nextFib(Fib1, Fib2, NextFib) :- NextFib is Fib1 + Fib2.
popout

content may be truncated. 'popout' for larger text window.

actions get anonymous link download benchmark