Facebook
From Fiery Marten, 8 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 322
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApplication1
  8. {
  9.     class Program
  10.     {
  11.  
  12.         static int Fib(int n)
  13.         {
  14.             int s = 0;
  15.             if (n == 1 || n == 2) return s = 1;
  16.             else return s = Fib(n - 1) + Fib(n - 2);
  17.         }
  18.  
  19.         static int NWD(int a, int b)
  20.         {
  21.             if (b == 0) return a;
  22.             else return NWD(b, a % b);
  23.         }
  24.  
  25.         static int Aryt(int a1, int r, int n)
  26.         {
  27.             if (n == 1) return a1;
  28.             else return Aryt(a1, r, (n - 1))+r;
  29.         }
  30.  
  31.         static int Geo(int a1, int r, int n)
  32.         {
  33.             if (n == 1) return a1;
  34.             else return Aryt(a1, r, n) * r;
  35.         }
  36.  
  37.         static void Main(string[] args)
  38.         {
  39.             int a1,r,n;
  40.             Console.Write("Podaj a1: ");
  41.             a1 = Int32.Parse(Console.ReadLine());
  42.             Console.Write("Podaj r: ");
  43.             r = Int32.Parse(Console.ReadLine());
  44.             Console.Write("Podaj n: ");
  45.             n = Int32.Parse(Console.ReadLine());
  46.             Console.WriteLine("a1 {0} r {1} n {2} w {3}", a1, r, n, Geo(a1,r,n));
  47.             Console.ReadKey();
  48.         }
  49.     }
  50. }
  51.