命名空间"系统"中不存在类型或命名空间名称"Numerics"

Sto*_*boy 3 c# mono

我在Project Euler上解决问题25.我在C#中为它编写了一个代码.但是在这种情况下,我需要使用"BigInt",因为Int64不足以容纳数字.但是,当我放置时,它会在编译期间给出错误消息(标题中的消息).为什么是这样?我使用的是Mono 2.10.9.using System.Numerics;

我的代码:

using System;
using System.Numerics;

public class Problem_25{
    static BigInt fib(int n){
        double Phi = (1+Math.Sqrt(5))/2;
        double phi = (1-Math.Sqrt(5))/2;
        BigInt an = Convert.BigInt((Math.Pow(Phi, n)-(Math.Pow(phi, n)))/Math.Sqrt(5));
        return an;
    }
    static void Main(){
        int i = 100;
        int answer = 0;
        string current_fn = "1";
        while(true){
            current_fn = Convert.ToString(fib(i));
            if(current_fn.Length == 1000){
                answer = i;
                break;
            }
            else{
                i++;
            }
        }
        Console.WriteLine("Answer: {0}", answer);
    }
}
Run Code Online (Sandbox Code Playgroud)

SLa*_*aks 6

您需要添加对System.Numerics.dll的引用.

  • 我如何在Mono中做到这一点?我没有使用任何IDE.只是编译工具. (3认同)