Advertisement
Guest User

Untitled

a guest
Sep 24th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.83 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace ConsoleApp6
  7. {
  8.     class Program
  9.     {
  10.         static void Main()
  11.         {
  12.             double a;
  13.             long n;
  14.             double result = 1;
  15.             string input_1 = Console.ReadLine();
  16.             string input_2 = Console.ReadLine();
  17.             if (!double.TryParse(input_1, out a) | !long.TryParse(input_2, out n))
  18.             {
  19.                 Console.WriteLine("wrong");
  20.             }
  21.             else
  22.             {
  23.                 double pow = a;
  24.                 while (n > 0)
  25.                 {
  26.                     result = result + a;
  27.                     a *= pow;
  28.                     n -= 1;
  29.                 }
  30.                 Console.WriteLine($"{result:0.000}");
  31.             }
  32.         }
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement