﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Factorial
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        static void Main(string[] args)
        {
            int[] value = new int[] { 1, 2, 3, 4, 5 };
            int result = Sum(value.Length, value);
        }

        static int Sum(int lenght,int[] values)
        {
            if (lenght == 0) { return 0; }
            return Sum(lenght - 1, values) + values[lenght-1];
        }

        public void interactiveMod(double n)
        {
            double Result = 1;

            for (double i = 0; i < n; i++)
            {
                Result *= (n - i);
            }

            textBox.Text = Convert.ToString(Result);
        }

        public double RecursiveMod(double n)
        {
            if (n > 1) { return (n * RecursiveMod(n - 1));} else { return 1; }
        }

        public double RecursiveArrayMod(double n)
        {
            
        }


        private void buttonInt_Click(object sender, EventArgs e)
        {
            interactiveMod(Convert.ToDouble(textBox.Text));
        }

        private void buttonRec_Click(object sender, EventArgs e)
        {
            textBox.Text = Convert.ToString(RecursiveMod(Convert.ToDouble(textBox.Text)));
        }
    }
}
