例2) 質問PをN回繰り返す述語
repeat(N,P) :- N>0,P.
repeat(N,P) :- N>0,M is N-1,repeat(M,P).

ですね。
?- repeat(3,write(a)).
aaa
yes
?- というような実行になります。