Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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 lr4
- {
- public partial class SUmm : Form
- {
- public SUmm()
- {
- InitializeComponent();
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- }
- private void label2_Click(object sender, EventArgs e)
- {
- }
- private void b1_Click(object sender, EventArgs e)
- {
- const double eps = 0.0001;
- double x = Convert.ToDouble(tb1.Text);
- double result = GetSeriesSum(x, eps);
- l4.Text = Convert.ToString(result);
- }
- private static double GetSeriesSum(double x, double e)
- {
- int i = 1;
- double sum = 0, y = 1, lastsum = double.MinValue;
- while (Math.Abs(sum - lastsum) > e)
- {
- lastsum = sum;
- sum += (y *= x / i++);
- }
- return sum;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement