コード例 #1
0
    static void Main()
    {
        Fibbonacci fi = new Fibbonacci();

        TriangleNums tri = new TriangleNums();

        foreach (int numb in fi.nextMemb(7))
        {
            Console.Write(numb + "  ");
        }

        Console.WriteLine();

        foreach (double numb in tri.nextMemb(7))
        {
            Console.Write(numb + "  ");
        }

        Console.WriteLine();

        var fifi   = fi.nextMemb(7).GetEnumerator();
        var tritri = tri.nextMemb(7).GetEnumerator();

        for (int i = 0; i < 7; i++)
        {
            fifi.MoveNext();
            tritri.MoveNext();
            Console.Write((int)fifi.Current + (double)tritri.Current + "  ");
        }
    }
コード例 #2
0
        public void ShouldCalculateFor54()
        {
            //arrange
            Fibbonacci fib = new Fibbonacci();
            //act
            Int64 actualNumber = fib.CalculateFibonnacciNumber(54);

            //assert
            actualNumber.Should().Be(1485L);
        }
コード例 #3
0
        public void ShouldTake0AndReturn0()
        {
            //arrange
            Fibbonacci fib = new Fibbonacci();
            //act
            Int64 actualNumber = fib.CalculateFibonnacciNumber(0);

            //assert
            actualNumber.Should().Be(0);
        }
コード例 #4
0
    static void Main()
    {
        Fibbonacci fi = new Fibbonacci();

        foreach (int numb in fi.NextMemb(7))
        {
            Console.Write(numb + " ");
        }
        Console.WriteLine();
        foreach (int numb in fi.NextMemb(7))
        {
            Console.Write(numb + " ");
        }
        Console.WriteLine();
    }
コード例 #5
0
        internal static int Solve()
        {
            Timer timer = new Timer();

            timer.Begin();
            var fibbonacci = new Fibbonacci(1, 2);

            while (fibbonacci.Num2 < 4000000)
            {
                fibbonacci.Next();
            }
            var evens = fibbonacci.Sequence.Where(x => x % 2 == 0);

            return(evens.Sum());
        }
コード例 #6
0
    static void Main()
    {
        Fibbonacci fi  = new Fibbonacci();
        var        fib = fi.NextMemb(7).ToArray();

        TriangleNumbers triangleNumbers = new TriangleNumbers();
        var             tr = triangleNumbers.NextMemb(7).ToArray();

        Console.WriteLine("Fib");
        Array.ForEach(fib, Console.WriteLine);
        Console.WriteLine("triangle");
        Array.ForEach(tr, Console.WriteLine);
        Console.WriteLine("+");
        for (int i = 0; i < Math.Max(tr.Count(), fib.Count()); i++)
        {
            Console.WriteLine(tr[i] + fib[i]);
        }
    }
コード例 #7
0
        public void RedisCacheFibonacci()
        {
            var fibbonacci = new Fibbonacci(new FiboRedisCache("localhost"));

            Console.WriteLine(fibbonacci.Get(10));
        }
コード例 #8
0
        public void MemoryCacheFibonacci()
        {
            var fibbonacci = new Fibbonacci(new FiboMemoryCache());

            Console.WriteLine(fibbonacci.Get(10));
        }