Revision: 40749
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at February 7, 2011 07:33 by 13tazer31
Initial Code
largest_prime_factor(Number, Prime) :- N is round(sqrt(Number)), largest_prime_factor(Number, N, Prime). largest_prime_factor(Number, N, N) :- divisible(Number, N), prime(N), !. largest_prime_factor(Number, N, Prime) :- Next is N-1, largest_prime_factor(Number, Next, Prime). divisible(Number, 0) :- write('Error: division by 0'). divisible(Number, Divisor) :- Number mod Divisor =:= 0. prime(Number) :- N is round(sqrt(Number)), prime(Number, 1, N). prime(Number, N, N) :- !. prime(Number, Divisor, End) :- Divisor < End, NextDivisor is Divisor + 1, \+ divisible(Number, NextDivisor), prime(Number, NextDivisor, End).
Initial URL
http://13tazer31.wordpress.com/2011/02/06/project-euler-problem-3/
Initial Description
Initial Title
Project Euler - Problem 3
Initial Tags
Initial Language
Prolog