提问人:Ali jafari 提问时间:7/19/2023 更新时间:7/19/2023 访问量:56
在 C# 代码中使用 BigInteger 类型的问题
Problem with using BigInteger type in C# code
问:
我是 C# 的新手,我正在尝试为斐波那契数列编写代码。在代码中使用 BigInteger 类型时出现错误。 如果您能帮助我解决这个问题,我将不胜感激。
这是我的代码:
using System;
using System.Numerics;
namespace FibonacciSequence
{
class Program
{
static void Main(string[] args)
{
int start = Environment.TickCount;
BigInteger i1 = 1;
BigInteger i2 = 1;
Console.WriteLine(i1);
int count = 0;
while (true)
{
if (count++ % 100000 == 0)
{
Console.WriteLine(i2);
}
BigInteger next = i1 + i2;
i1 = i2;
i2 = next;
}
int end = Environment.TickCount;
Console.WriteLine(end - start);
}
}
}
这是错误:
“找不到类型或命名空间名称'BigInteger'(是否缺少 using 指令或程序集引用?
答: 暂无答案
评论
System.Numerics.dll
。