Seal_of_approval

Pr5R4ex1

Sep 17th, 2015
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.50 KB | None | 0 0
  1. using System;
  2.  
  3. namespace test
  4. {
  5.     class Program
  6.     {
  7.         static int Func (int a, int b, int i, int n)
  8.         {
  9.             if (n == 1)
  10.                 return a;
  11.             if (n == 2)
  12.                 return b;
  13.             int new_a = Math.Abs (a) - 6 * b;
  14.             if (i < n - 2)
  15.                 return Func (new_a, a, i++, n);
  16.             else
  17.                 return new_a;      
  18.         }
  19.         static void Main ()
  20.         {
  21.             Console.WriteLine ("Enter n ");
  22.  
  23.             int n = int.Parse (Console.ReadLine ());
  24.  
  25.             int res = Func (-10, 2, 1, n);
  26.             Console.WriteLine ("Result = {0} ", res);
  27.         }
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment