fork download
  1. using System;
  2. using System.Numerics;
  3.  
  4. public class Test
  5. {
  6. public static void Main()
  7. {
  8. var fibs = new Fibonacci();
  9. for (var i = 0; i < 20; i++)
  10. {
  11. Console.WriteLine(fibs.Calculate(i));
  12. }
  13.  
  14. Console.WriteLine(fibs.Calculate(10000));
  15. Console.WriteLine(fibs.Calculate(20000));
  16. }
  17. }
  18.  
  19. internal class Fibonacci
  20. {
  21. private readonly List<BigInteger> fibs = new List<BigInteger>
  22. {
  23. BigInteger.Zero,
  24. BigInteger.One
  25. };
  26.  
  27. public BigInteger Calculate(int ordinalPosition)
  28. {
  29. if (ordinalPosition < 0)
  30. {
  31. throw new ArgumentOutOfRangeException("ordinalPosition", "ordinalPosition is less than zero.");
  32. }
  33.  
  34. for (var i = this.fibs.Count; i <= ordinalPosition; i++)
  35. {
  36. this.fibs.Add(BigInteger.Add(this.fibs[i - 1], this.fibs[i - 2]));
  37. }
  38.  
  39. return this.fibs[ordinalPosition];
  40. }
  41. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cs(2,14): error CS0234: The type or namespace name `Numerics' does not exist in the namespace `System'. Are you missing an assembly reference?
prog.cs(27,16): error CS0246: The type or namespace name `BigInteger' could not be found. Are you missing a using directive or an assembly reference?
Compilation failed: 2 error(s), 0 warnings
stdout
Standard output is empty