private IOperationResult CalculateSequence(SequenceTask operation)
        {
            var sequence = new List <int>();

            for (int i = 0; i *i < operation.End; i++)
            {
                sequence.Add(i);
            }

            return(MathOperationResult.SetResult(sequence.ToArray()));
        }
Exemple #2
0
        private IOperationResult CalculateFibonacci(FibonacciTask operation)
        {
            var a = operation.Start;
            var b = 1;

            var numbersFibonacci = new List <int>();

            for (
                int index = operation.Start;
                a <= operation.End;
                index++
                )
            {
                numbersFibonacci.Add(a);

                var temp = a;
                a = b;
                b = temp + b;
            }

            return(MathOperationResult.SetResult(numbersFibonacci.ToArray()));
        }