{ $a=abs($a);
$b=abs($b);
if ($a==0 ||$b==0)
return $a+$b;
while ($a !=$b)
{
if($a>$b)
$a=$a-$b;
else
$b=$b-$a;
}
return $a;
}
echo ucln(42,56);
trong C#
static int USCLN(int a, int b)
{
a=Math.Abs(a);
b=Math.Abs(b);
if (a==0 ||b==0)
return a+b;
while (a !=b)
{
if(a>b)
a=a-b;
else
b=b-a;
}
return a;
}
[caption id="" align="alignnone" width="241" caption="ucnn"][/caption]
No comments: