Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace ConsoleApp6
- {
- internal class Program
- {
- static void Main(string[] args)
- {
- int Factorial(int n)
- {
- if (n == 1) return 1;
- if (n == 0) return 1;
- return n * Factorial(n - 1);
- }
- double lim = 0.0001, abs_sum = 0, cur_n = double.PositiveInfinity;
- int i = 0;
- while(cur_n >= lim)
- {
- double cur_sum = 0;
- for (double x = 0.1; x <= 1; x += 0.05)
- {
- double up = 1, dn = 1;
- for (int n = 0; n < i; n++)
- {
- up *= 2 * x;
- }
- dn = Factorial(i);
- cur_sum += up / dn;
- Console.WriteLine($"y == {Math.Pow(Math.E, 2*x)}");
- }
- if (cur_sum >= lim)
- {
- abs_sum += cur_sum;
- i++;
- }
- cur_n = cur_sum;
- }
- Console.WriteLine($"\ns = {abs_sum} {i}");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment