Advertisement
fieldtarget

Untitled

Sep 23rd, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Problem_F
  8. {
  9. class Program
  10. {
  11. public static void Monom (double a, int n, ref double polynomial)
  12. {
  13. int i = 1;
  14. double monomial=a;
  15. polynomial = 1;
  16. while (i<n+1)
  17. {
  18. polynomial += monomial;
  19. monomial = monomial * a;
  20. i++;
  21. }
  22. }
  23. static void Main(string[] args)
  24. {
  25. double a, polynomial=1;
  26. int n;
  27. if (!double.TryParse(Console.ReadLine(), out a) || (!int.TryParse(Console.ReadLine(), out n))||(n<1))
  28. Console.WriteLine("wrong");
  29. else
  30. {
  31. Monom(a, n, ref polynomial);
  32. Console.WriteLine(Math.Round(polynomial, 5));
  33. }
  34. }
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement