Skip to content

Instantly share code, notes, and snippets.

@Euler29
Created March 17, 2018 07:39
Show Gist options
  • Save Euler29/135150ab65495616897b6af9df4d623e to your computer and use it in GitHub Desktop.
Save Euler29/135150ab65495616897b6af9df4d623e to your computer and use it in GitHub Desktop.
BasicLinearDiaphontineEquationSolver
import math
def brute_diyafont(a,b,c):
x=0
y=(c-a*x)/b
while type(y)!=type(3.4):
x=x+1
return (x,int(y))
while True:
print("Lineer Diyafont Denklem programıma hoşgeldin")
print("ax+by=c denklemindeki a,b ve c değerlerini sırayla giriniz.")
a=int(input("a:"))
b=int(input("b:"))
c=int(input("c:"))
if c%math.gcd(a,b)==0:
print("Denklem için çözüm vardır.")
y=brute_diyafont(a,b,c)
print("ilk çözüm:",y)
h=math.gcd(a,b)
z=math.gcd(h,c)
print("Genel çözüm:","x=",y[0],"+",int(a/z),"k","y=",y[1],"+","-",int(b/z),"k")
q=int(input("Sonsuz çözümleri görmek için 2 yazın"))
if q==2:
k=-1
while True:
print("x=",y[0]+int(a/z)*k,"y=",y[1]+(-(int(b/z)*k)))
k+=1
else:
print("Denklem için çözüm yoktur.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment