Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- public class main
- {
- public static void Main(String[] args)
- {
- Console.WriteLine("Введите первый челен геометрической прогрессии:");
- int b = Convert.ToInt32(Console.ReadLine());
- Console.WriteLine("Введите знаменатель геометрической прогрессии:");
- int q = Convert.ToInt32(Console.ReadLine());
- Console.WriteLine("Введите i:");
- int i = Convert.ToInt32(Console.ReadLine());
- Console.WriteLine("Введите k:");
- int k = Convert.ToInt32(Console.ReadLine());
- Console.WriteLine(Rec(b,q,i,k));
- }
- public static int Rec(int b, int q, int i, int k, int sum = 0, int index = 0)
- {
- index++;
- if (index == k + 1) return sum;
- if (index >= i)
- {
- sum += b;
- }
- b *= q;
- return Rec(b, q, i, k, sum, index);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement