Blame view

code/asp/py_01.lp 291 Bytes
808facfe   Francisco Coelho   Main text adapted...
1
2
3
4
5
6
7
8
9
10
11
12
#script (python)

import clingo

N = clingo.Number

def gcd(a, b):
    if a.number == 0:
        return b
    else:
        na = a.number
        nb = b.number
53b3b48c   Francisco Coelho   Started pre-paper...
13
14
        nc = N(nb % na)
        return gcd(nc, a)
808facfe   Francisco Coelho   Main text adapted...
15
16
17
18
19

#end.

p(210, 213).
p(1364, 385).
53b3b48c   Francisco Coelho   Started pre-paper...
20
21
22
gcd(X, Y, @gcd(X,Y)) :- p(X, Y).

#show gcd/3.