Skip to content

Commit 5fb906a

Browse files
authored
Merge pull request #83 from MaximSmolskiy/fix_highest_common_factor
Fix highest common factor
2 parents ff0f575 + 6147fee commit 5fb906a

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
ffunction HCF = mini (x, y)
1+
function HCF = highest_common_factor (x, y)
22
%This function searches for highest common factor
33
%It first checks if any of the numbers equal to zero, if so the non zero number is the HCF
44
%If the numbers are different, you minus the bigger number by the smaller one and this is done by recursion.
55
if x==0
66
HCF = y;
77
elseif y==0
8-
HCF == x;
8+
HCF = x;
99
elseif (y == x)
1010
HCF = x;
1111
elseif (y>x)
12-
HCF = mini(y-x,x);
12+
HCF = highest_common_factor(y-x,x);
1313
else
14-
HCF = mini(x-y,y);
14+
HCF = highest_common_factor(x-y,y);
1515
end
1616

0 commit comments

Comments
 (0)