Answer on Question#39148- Programming, C#
1. To find factorial of a number by using interface.
Solution.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
int n = Convert.ToInt32(textBox1.Text); // number of cycles Factorial
int factorial = 1; // factorial value
// The cycle starts with 2, because it makes no sense to start with 1
for (int i = 2; i <= n; i++)
{ factorial = factorial * i; }
textBox2.Text = factorial.ToString();
}
}
}