3

I am solving problem 25 on Project Euler. I wrote a code for it in C#. However in this case I needed to use "BigInt", since Int64 wasn't big enough to hold the number. But, when I put using System.Numerics;, it gives an error message during compiling (the message in title). Why is this? I am using Mono 2.10.9.

My code:

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);
    }
}
sirius_x
  • 183
  • 4
  • 11
  • Also has an answer here: https://stackoverflow.com/questions/9824479/how-to-add-a-reference-to-system-numerics-dll – Xonatron Dec 11 '18 at 00:57

2 Answers2

6

You need to add a reference to System.Numerics.dll.

SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964
  • 3
    How would I do that in Mono? I am not using any IDE. Just the compiler tools. – sirius_x Aug 05 '13 at 20:18
  • @Stormboy, here is your answer: https://stackoverflow.com/questions/9824479/how-to-add-a-reference-to-system-numerics-dll – Xonatron Dec 11 '18 at 00:57
3
mcs -r:System.Numerics.dll main.cs

man mcs should do you the honours.

Depending on your mono version you might want to use dmcs and/or upgrade.

Oh, and it's BigInteger, not BigInt

sehe
  • 374,641
  • 47
  • 450
  • 633