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_F
- {
- class Program
- {
- public static void Monom (double a, int n, ref double polynomial)
- {
- int i = 1;
- double monomial=a;
- polynomial = 1;
- while (i<n+1)
- {
- polynomial += monomial;
- monomial = monomial * a;
- i++;
- }
- }
- static void Main(string[] args)
- {
- double a, polynomial=1;
- int n;
- if (!double.TryParse(Console.ReadLine(), out a) || (!int.TryParse(Console.ReadLine(), out n))||(n<1))
- Console.WriteLine("wrong");
- else
- {
- Monom(a, n, ref polynomial);
- Console.WriteLine(Math.Round(polynomial, 3));
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement