| |
|
|
p.specht
| Diophantus de Alexandria gilt comme qui bedeutendste Mathematiker qui Antike. il schrieb encore sur Pergamentrollen et wirkte um ca. 250 pour Christus. avant allem beschäftigte il sich avec praktischen Fragen des Handels, insbesondere avec GANZZAHLIGEN Aufgaben. Daher appeler derartige Aufgabenstellungen aujourd'hui "Diophantische Gleichungen".
Titre de la fenêtre upper$("Diophantische (ganzzahlig trop lösende) Gleichungen")
' Q: https://jean-pierre.moreau.pagesperso-orange.fr/Fortran/diophan_f90.txt
' (D) Demoware 2015-07 de F90 pour XProfan-11 by P.Specht, vienne
' Demo only. Original Copyright applies fully. sans jegliche Gewähr!
Fenêtre Style 24:font 2:randomize:set("Décimal",10)
CLS : var TRUE&=1:var FALSE&=0
'**********************************************
'* Solving a diophantian equation ax+by = c *
'* (a,b,c,x,y sont integer numbers) *
'* ------------------------------------------ *
'* Ref.: "Mathématiques en Turbo-Pascal *
'* By M. Ducamp and A. Reverchon (2), *
'* Eyrolles, Paris, 1988" *
'* ------------------------------------------ *
'* Sample run: *
'* *
'* SOLVING IN Z EQUATION AX + BY = C *
'* *
'* A = 3 *
'* B = -2 *
'* C = 7 *
'* *
'* Solutions sont: *
'* *
'* X = 1 + 2*K *
'* Y = -2 + 3*K *
'* *
'* F90 Version By J-P Moreau. *
'* (www.jpmoreau.fr) *
'**********************************************
'* XProfan-11 Version By P.Specht, Vienna *
'**********************************************
Déclarer a!,b!,c!,p!,q!,x0!,y0!,iresult!,Diophantian!
Dio_Main:
Claire a!,b!,c!,p!,q!,x0!,y0!,iresult!,Diophantian!
imprimer "\n---------------------------------------------------------"
imprimer " LÖSE DIE ALL-GANZZAHLIGE GLEICHUNG: a * X + b * Y = c "
imprimer "---------------------------------------------------------"
Imprimer " a = ";:input a!
Imprimer " b = ";:input b!
Imprimer " c = ";:input c!
imprimer "---------------------------------------------------------"
iresult! = Diophantian(a!,b!,c!)
si iresult!>0
imprimer " Lösungen:\n\n X= Y= "
imprimer tab(4-(x0!<0));format$("%g",x0!)," + ";format$("%g",abs(q!));" * K"
si (p!*q!)>0
imprimer tab(4-(Y0!<0));format$("%g",y0!)," - ";format$("%g",abs(p!));" * K"
d'autre
imprimer tab(4-(Y0!<0));format$("%g",y0!)," + ";format$("%g",abs(p!));" * K"
endif
imprimer "\n avec K = {...,-3,-2,-1,0,+1,+2,+3,...} "
d'autre
font 0:beep:imprimer "\n aucun Lösungen trouvé!"
endif
font 2:imprimer "---------------------------------------------------------\n"
Waitinput 60000
cas %csrlin>50:cls
GOTO "Dio_Main"
proc Diophantian :parameters a!,b!,c!
'***********************************************************
'* Solving equation ax+by=c, a,b,c,x,y sont integer numbers *
'* ------------------------------------------------------- *
'* INPUT: a,b,c coefficients of equation *
'* OUTPUT: solutions sont x0+kp and y0-kq, with k=0,1,2... *
'* or k=-1,-2,-3... *
'* The function returns TRUE si solutions exist (that is, *
'* si le GCD of a,b is alors a divisor of c). *
'***********************************************************
'Integer Function Diophantian(a,b,c,x0,y0,p,q)
Var TRUE!=1 : Var FALSE!=0
declare aa!,bb!,pg!,x1!,x2!,y1!,y2!
declare ifound!,GCD!,Diophantian!
Diophantian!=FALSE!
Cas (a!=0) Or (b!=0):goto "Dio_return"
aa!=a!:bb!=b!'Send copies of a and b to function GCD!
pg! = GCD(aa!,bb!)'(XProfan kapselt eigentlich de toute façon selbst)
a!=a!/pg!:b!=b!/pg!:c!=c!/pg!
Cas c!<>INT(c!):goto "Dio_return"' pg must être alors a divisor of c
x1!=0: y2!=0 : ifound!=FALSE!
Dio_10:
y1!=(c!-a!*x1!)/b!
si y1!=INT(y1!)
x0!=x1!:y0!=y1!
ifound!=TRUE!
d'autre
x1!=-x1!:cas x1!>=0:x1!=x1!+1
x2!=(c!-b!*y2!)/a!
si x2!=INT(x2!)
x0!=x2!: y0!=y2!: ifound!=TRUE!
d'autre
y2!=-y2!:cas y2!>=0:y2!=y2!+1
endif
endif
cas ifound!=FALSE!:goto "Dio_10"
p!=a! : q!=b!
Diophantian!=TRUE!
Dio_return:
return Diophantian!
ENDPROC
Proc GCD :parameters a!,b!
' Greatest common divisor of two integer numbers
declare r!,temp!,GCD!
a!=int(abs(a!)):b!=int(abs(b!))
si (a!>10^10) or (b!>10^10):GCD!=1:goto "gcd_exit":endif
si (a!=0) OU (b!=0):GCD!=1:goto "gcd_exit":endif
si a!<B!:temp!=a!:a!=b!:b!=temp!:endif
GCD_1010:
r!=a!-b!*int(a!/b!):a!=b!:b!=r!
cas (abs(r!)>10^-10):goto "GCD_1010"
GCD!=a!
GCD_exit:
return gcd!
endproc
|
|
|
| XProfan 11Computer: Gerät, daß es in Mikrosekunden erlaubt, 50.000 Fehler zu machen, zB 'daß' statt 'das'... | 19.05.2021 ▲ |
|
|
|