Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Problem_G
- {
- class Program
- {
- public static void Term (int N, ref double Sum)
- {
- Sum = 1;
- double fact = 1;
- for (int i = 1; i <= N; i++)
- {
- fact = fact*(1.0/i);
- if (Sum.Equals(double.PositiveInfinity))
- Console.WriteLine(5);
- Sum += fact;
- }
- }
- static void Main(string[] args)
- {
- double Sum=1;
- int N;
- if (!int.TryParse(Console.ReadLine(), out N) || (N<1))
- Console.WriteLine("wrong");
- else
- {
- Term(N, ref Sum);
- Console.WriteLine(Math.Round(Sum, 5));
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement