 <p>Why not use <a href="/questions/tagged/clpfd" class="post-tag" title="show questions tagged &#39;clpfd&#39;" rel="tag">clpfd</a>?</p> <p>Building on <a href="http://stackoverflow.com/a/30346715/4609915">my previous answer</a> to a <a href="http://stackoverflow.com/questions/10925285/faster-implementation-of-verbal-arithmetic-in-prolog">very related question</a>, we query:</p> <pre><code>?- solve_n_dump([A,M] + [P,M] #= [D,A,Y]). Eq = ([2,5]+[9,5]#=[1,2,0]), Zs = [2,5,9,1,0]. Eq = ([2,7]+[9,7]#=[1,2,4]), Zs = [2,7,9,1,4]. Eq = ([2,8]+[9,8]#=[1,2,6]), Zs = [2,8,9,1,6]. Eq = ([3,5]+[9,5]#=[1,3,0]), Zs = [3,5,9,1,0]. Eq = ([3,6]+[9,6]#=[1,3,2]), Zs = [3,6,9,1,2]. Eq = ([3,7]+[9,7]#=[1,3,4]), Zs = [3,7,9,1,4]. Eq = ([3,8]+[9,8]#=[1,3,6]), Zs = [3,8,9,1,6]. Eq = ([4,5]+[9,5]#=[1,4,0]), Zs = [4,5,9,1,0]. Eq = ([4,6]+[9,6]#=[1,4,2]), Zs = [4,6,9,1,2]. Eq = ([4,8]+[9,8]#=[1,4,6]), Zs = [4,8,9,1,6]. Eq = ([5,6]+[9,6]#=[1,5,2]), Zs = [5,6,9,1,2]. Eq = ([5,7]+[9,7]#=[1,5,4]), Zs = [5,7,9,1,4]. Eq = ([5,8]+[9,8]#=[1,5,6]), Zs = [5,8,9,1,6]. Eq = ([6,5]+[9,5]#=[1,6,0]), Zs = [6,5,9,1,0]. Eq = ([6,7]+[9,7]#=[1,6,4]), Zs = [6,7,9,1,4]. Eq = ([7,5]+[9,5]#=[1,7,0]), Zs = [7,5,9,1,0]. Eq = ([7,6]+[9,6]#=[1,7,2]), Zs = [7,6,9,1,2]. Eq = ([7,8]+[9,8]#=[1,7,6]), Zs = [7,8,9,1,6]. Eq = ([8,5]+[9,5]#=[1,8,0]), Zs = [8,5,9,1,0]. Eq = ([8,6]+[9,6]#=[1,8,2]), Zs = [8,6,9,1,2]. Eq = ([8,7]+[9,7]#=[1,8,4]), Zs = [8,7,9,1,4]. true. </code></pre>