Ladies and gentlemen let me proudly present the last question (which is the same since two weeks): Which programming language is it?
Today I implemented the Euclid algorithm to find the greatest common divisor. You can check your answer by using the right compiler :).
Please send your answers to: patrick.plattes@googlemail.com
All user with the right answer ’till 14pm will get the points, but the first one will get +25.
PROC greatest_common_divisor = (INT r, m) INT: (
IF r = 0 THEN
m
ELIF m = 0 THEN
r
ELIF r > m THEN
greatest_common_divisor(m, r MOD m)
ELSE
greatest_common_divisor(r, m MOD r)
FI
);
examples:(
INT a = 512, b = 256;
INT c = 42, d = 8471;
INT e = 8832, f = 847212;
printf(($x"The greatest common divisor of"g" and "g" is "gl$,a,b,greatest_common_divisor(a,b)));
printf(($x"The greatest common divisor of"g" and "g" is "gl$,c,d,greatest_common_divisor(c,d)));
printf(($x"The greatest common divisor of"g" and "g" is "gl$,e,f,greatest_common_divisor(e,f)))
)
Points: 50