schneller GGT-Algorithmus
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | #!/usr/bin/env python
#
# euklidGCD.py
# A Python implementation of the euklid algorythm for calculation the greatest common divisor.
#
# This script needs for the example only 6 loops, the slow one needs 9.
#
# Created by Lukas Klein on 07.11.08.
# Copyright (c) 2008 Xairro.com. All rights reserved.
#
def getGCD(number1, number2):
if number2==0:
return number1
else:
return getGCD(number2, number1%number2)
print getGCD(2254, 1472)
|