Öklit Algoritması İle Obeb Bulma(PYTHON)
Obeb bulma yöntemlerinden birisi de Öklit Algoritmasıdır.Detaylı bilgiyi buradan bulabilirsiniz.İşte öklit algoritmasının python üzerinde basit bir örneği:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
x=int(input("x:")) | |
y=int(input("y:")) | |
import math | |
def oklit_alg(x,y): | |
if y>x: | |
return oklit_alg(y,x) | |
while y!=0: | |
print("{}={}.{}+{}".format(x,math.floor(x/y),y,x%y)) | |
(x,y)=(y,x%y) | |
print("ebob:",x) | |
return x | |
try: | |
oklit_alg(x,y) | |
input() | |
except Exception as e: | |
print(str(e)) | |
input() |
Yorumlar
Yorum Gönder