class Loop
{
public static int Add(int num1, int num2)
{
if (num2 == 0)
return num1;
return Add(num1 ^ num2, (num1 & num2) << 1);
}
static void Main()
{
Console.WriteLine(Add(12, 9));
Console.ReadLine();
}
}
Output:
21
No comments:
Post a Comment