int liczba = int.Parse(txtliczba.Text); int suma = 0; for (int i = 0; i < liczba; i++) { suma = suma + i; } MessageBox.Show("Suma wynosi " + suma);