Anonymous user
Ethiopian multiplication: Difference between revisions
{{header|C sharp|C#}}
({{header|C sharp|C#}}) |
|||
Line 309:
}
</lang>
=={{header|C sharp|C#}}==
<lang csharp>
static void Main(string[] args)
{
EthopianMultiplication(17, 34);
Console.ReadKey();
}
static int Half(int value)
{
return value >> 1;
}
static int Double(int value)
{
return value << 1;
}
static bool Even(int value)
{
return (value % 2) == 0;
}
static void EthopianMultiplication(int lhs, int rhs)
{
int total = 0;
int col1 = lhs;
int col2 = rhs;
while (col1 > 0)
{
Console.WriteLine("{0,4} | {1,4}", col1, col2);
if (!Even(col1))
{
total = total + col2;
}
col1 = Half(col1);
col2 = Double(col2);
}
Console.WriteLine("Total = {0}", total);
}</lang>
=={{header|ColdFusion}}==
|