Skip to content

Commit f333457

Browse files
committed
factors.pl
1 parent 5bef489 commit f333457

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

factors.pl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
% factors(N,Fs) <- Fs is the list of prime factors of N
2+
factors(1,[1]).
3+
factors(X,[Factor|Fs]) :-
4+
X > 1,
5+
between(2,X,Factor), % generate candidate factor, lowest first
6+
(X mod Factor) =:= 0, % test Factor is divisor of X
7+
!, % if so, stop generating!
8+
Rem is X // Factor, % proceed with remainder
9+
factors(Rem,Fs).
10+
11+
/** &lt;examples&gt;
12+
13+
?-factors(27,Fs).
14+
?-factors(28,Fs).
15+
?-factors(29,Fs).
16+
17+
*/

tiles.pl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
board_size(7). % odd number, at least 3
1+
board_size(9). % odd number, at least 3
22

33
eval_pos(Pos,Value):-
44
%% uncomment exactly one of the following lines
5-
bLeftOfw(Pos,Value).
6-
%outOfPlace(Pos,1,Value).
5+
%bLeftOfw(Pos,Value).
6+
outOfPlace(Pos,1,Value).
77

88
/*
99
* Moves are represented as triples m(From,To,Cost).

0 commit comments

Comments
 (0)