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;
- class Program
- {
- static double answer(long n) {
- double result = 1;
- double m = 1.0;
- long b = 2;
- while (n > 0)
- {
- result = result + (1 / m);
- m *= b;
- b += 1;
- n = n - 1;
- }
- return result;
- }
- static void Main()
- {
- long n;
- string input = Console.ReadLine();
- if (!long.TryParse(input, out n))
- {
- Console.WriteLine("wrong");
- }
- else {
- Console.WriteLine($"{answer(n):0.00000}");
- Console.ReadLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement