public ActionResult Index(int?number) { var data = Fibonacci.Compute(number); var model = new IndexModel(data); return(View(model)); }
public void Fibonacci_Test() { var fibonacciComputer = new Fibonacci(); var res = fibonacciComputer.Compute(8); Assert.That(res, Is.Not.Null); Assert.AreEqual(res, 21); }
static void Main(string[] args) { Fibonacci f = new Fibonacci(); int n = 8; var result = f.Compute(n); Console.WriteLine($"The {n}th fibonacci number is: {result}"); }
public void FibonacciNumberWithinAllowedRangeTest(int sequenceSize, int expected) { // Arrange var fibo = new Fibonacci(100); // Act var fiboNbr = fibo.Compute(sequenceSize); // Assert Assert.AreEqual(expected, fiboNbr); }
public int Fibonacci(int n) { int result; try { var fibo = new Fibonacci(100); result = fibo.Compute(n); } catch (ArgumentException exception) { Console.Error.WriteLine(exception); return(-1); } return(result); }
public static IHostBuilder CreateHostBuilder(string[] args) { return(Host.CreateDefaultBuilder(args).ConfigureWebHostDefaults(webBuilder => { webBuilder.Configure(app => { app.UseRouting(); app.UseEndpoints(endpoints => { endpoints.MapGet("/Fibonacci", async context => { await context.Response.WriteAsync( JsonConvert.SerializeObject(Fibonacci.Compute(new[] { "44", "43" }))); }); }); }); })); }
public void FibonacciSimpleTests() { Assert.AreEqual(expected: (uint)0, actual: Fibonacci.Compute(0)); Assert.AreEqual(expected: (uint)1, actual: Fibonacci.Compute(1)); Assert.AreEqual(expected: (uint)1, actual: Fibonacci.Compute(2)); Assert.AreEqual(expected: (uint)2, actual: Fibonacci.Compute(3)); Assert.AreEqual(expected: (uint)3, actual: Fibonacci.Compute(4)); Assert.AreEqual(expected: (uint)5, actual: Fibonacci.Compute(5)); Assert.AreEqual(expected: (uint)8, actual: Fibonacci.Compute(6)); Assert.AreEqual(expected: (uint)13, actual: Fibonacci.Compute(7)); Assert.AreEqual(expected: (uint)21, actual: Fibonacci.Compute(8)); Assert.AreEqual(expected: (uint)34, actual: Fibonacci.Compute(9)); Assert.AreEqual(expected: (uint)55, actual: Fibonacci.Compute(10)); Assert.AreEqual(expected: (uint)89, actual: Fibonacci.Compute(11)); Assert.AreEqual(expected: (uint)144, actual: Fibonacci.Compute(12)); Assert.AreEqual(expected: (uint)233, actual: Fibonacci.Compute(13)); Assert.AreEqual(expected: (uint)377, actual: Fibonacci.Compute(14)); Assert.AreEqual(expected: (uint)610, actual: Fibonacci.Compute(15)); Assert.AreEqual(expected: (uint)987, actual: Fibonacci.Compute(16)); Assert.AreEqual(expected: (uint)1597, actual: Fibonacci.Compute(17)); Assert.AreEqual(expected: (uint)2584, actual: Fibonacci.Compute(18)); Assert.AreEqual(expected: (uint)4181, actual: Fibonacci.Compute(19)); Assert.AreEqual(expected: (uint)6765, actual: Fibonacci.Compute(20)); Assert.AreEqual(expected: (uint)10946, actual: Fibonacci.Compute(21)); Assert.AreEqual(expected: (uint)17711, actual: Fibonacci.Compute(22)); Assert.AreEqual(expected: (uint)28657, actual: Fibonacci.Compute(23)); Assert.AreEqual(expected: (uint)46368, actual: Fibonacci.Compute(24)); Assert.AreEqual(expected: (uint)75025, actual: Fibonacci.Compute(25)); Assert.AreEqual(expected: (uint)121393, actual: Fibonacci.Compute(26)); Assert.AreEqual(expected: (uint)196418, actual: Fibonacci.Compute(27)); Assert.AreEqual(expected: (uint)317811, actual: Fibonacci.Compute(28)); Assert.AreEqual(expected: (uint)514229, actual: Fibonacci.Compute(29)); Assert.AreEqual(expected: (uint)832040, actual: Fibonacci.Compute(30)); Assert.AreEqual(expected: (uint)1346269, actual: Fibonacci.Compute(31)); Assert.AreEqual(expected: (uint)2178309, actual: Fibonacci.Compute(32)); Assert.AreEqual(expected: (uint)3524578, actual: Fibonacci.Compute(33)); }
public void FibonacciNumberPositionGreaterThanLimitMaxTest() { var fibo = new Fibonacci(100); Assert.Throws <ArgumentException>(() => fibo.Compute(101)); }
public void FibonacciNumberPositionlowerthanOneTest() { var fibo = new Fibonacci(100); Assert.Throws <ArgumentException>(() => fibo.Compute(0)); }
public void ComputesNthNumberInFibonacciSequence(int n, int expected) { Assert.Equal(expected, Fibonacci.Compute(n)); }
public void Execute44ShouldRetrun701408733() { var result = Fibonacci.Compute(new[] { "44" }); Assert.Equal(701408733, result[0]); }