Calc = {}
a = 5
b = 5
function Calc:PGCD(a,b)
 while b ~= a do
  if a > b then
   a = a - b
  end
  if b > a then
   b = b - a
  end
 end
 return a
end

while true do
screen:clear()
pad = Controls.read()
Android:Barre()
if pad:l() then
 if pad:up() and not oldpad:up() or pad:analogY()<-100 then
  a=a+1
 end
 if a>3 and pad:down() and not oldpad:down() or pad:analogY()>100 then
  a=a-1
 end
end
if pad:r() then
 if pad:up() and not oldpad:up() or pad:analogY()<-100 then
  b=b+1
 end
 if a>3 and pad:down() and not oldpad:down() or pad:analogY()>100 then
  b=b-1
 end
end

screen:print(50,30,"haut+l: a+1;bas+l: a-1",Color.new(255,0,0))
screen:print(50,40,"bas+r: b+1;bas+r: b-1",Color.new(255,0,0))
screen:print(50,60,"PGCD("..a..";"..b..")="..Calc:PGCD(a,b),Color.new(255,255,255))

if pad:square() and not oldpad:square() then
 Android:Quitter()
 end
oldpad = pad
screen.flip()
screen.waitVblankStart()
end
