2011-04-01 19:34:24 +00:00
|
|
|
divisible_3_5(N) :- 0 is N rem 3 ; 0 is N rem 5.
|
2011-03-31 22:32:48 +00:00
|
|
|
|
2011-04-01 19:34:24 +00:00
|
|
|
sum_divisors(End, End, Total, Total).
|
|
|
|
sum_divisors(Start, End, Acc, Total) :- divisible_3_5(Start), Next is Start + 1, NewAcc is Acc + Start, sum_divisors(Next, End, NewAcc, Total).
|
|
|
|
sum_divisors(Start, End, Acc, Total) :- Next is Start + 1, sum_divisors(Next, End, Acc, Total).
|
2011-04-01 00:28:23 +00:00
|
|
|
|
2011-04-01 19:34:24 +00:00
|
|
|
e1(Result) :- sum_divisors(2, 1000, 0, Result).
|