GITLAB

Francisco Coelho / zugzwang

Sign in
  • Sign in
  • Project
  • Files
  • Commits
  • Network
  • Graphs
  • Issues 0
  • Merge Requests 0
  • Wiki
  • zugzwang
  • code
  • asp
  • drafts
  • py_01.lp
  • 3e0f9b8a   back to work? Browse Code ยป
    Francisco Coelho
    2024-01-30 11:08:02 +0000  
py_01.lp 291 Bytes
Edit Raw Blame History
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
#script (python)

import clingo

N = clingo.Number

def gcd(a, b):
    if a.number == 0:
        return b
    else:
        na = a.number
        nb = b.number
        nc = N(nb % na)
        return gcd(nc, a)

#end.

p(210, 213).
p(1364, 385).
gcd(X, Y, @gcd(X,Y)) :- p(X, Y).

#show gcd/3.