Return to Snippet

Revision: 40744
at February 7, 2011 02:47 by 13tazer31


Initial Code
sum(N, N, N). 
sum(Start, End, Total) :-
	Start < End,
	applicable(Start),
	Next is Start + 1,
	sum(Next, End, SemiTotal),
	Total is SemiTotal + Start, !.
sum(Start, End, Total) :-
	Start < End,
	Next is Start + 1,
	sum(Next, End, Total).


applicable(Number) :-
	divisible(Number, 3).
applicable(Number) :-
	divisible(Number, 5).


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

Initial URL
http://13tazer31.wordpress.com/2011/02/06/problem-1/

Initial Description

                                

Initial Title
Project Euler - Problem 1

Initial Tags
math

Initial Language
Prolog