我是C#的新手并且遇到了以下代码的问题(我的目标框架为4.5,我添加了对System.Numerics的引用):
using System;
using System.Numerics;
namespace Test
{
class Program
{
static BigInteger Gcd(BigInteger x, BigInteger y)
{
Console.WriteLine("GCD {0}, {1}", x, y);
if (x < y) return Gcd(y, x);
if (x % y == 0) return y;
return Gcd(y, x % y);
}
static void Main(string[] args)
{
BigInteger a = 13394673;
BigInteger b = 53578691;
Gcd(a, b);
}
}
}
Run Code Online (Sandbox Code Playgroud)
当通过调试启动发布版本时(Visual Studio中的F5 - 以及程序结束时的断点,以便我可以看到输出),我得到以下输出:
GCD 13394673, 53578691
GCD 53578691, 13394673
GCD 13394673, 13394672
GCD 13394672, 1
Run Code Online (Sandbox Code Playgroud)
但是,在没有调试(Ctrl-F5)的情况下启动发布版本时,我得到以下内容:
GCD …Run Code Online (Sandbox Code Playgroud)