Advertisement
BojidarDosev

Rekursiq a na stepen n-ta

Oct 1st, 2021
916
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. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApp3
  8. {
  9.     class Program
  10.     {
  11.             static int Sbor(int a,int n)
  12.             {
  13.                 if (n == 1) return a;
  14.             if (n == 0) return 1;
  15.                return (a * Sbor(a,n - 1));
  16.             }
  17.  
  18.             static void Main(string[] args)
  19.             {
  20.                 Console.WriteLine(Sbor(2,4));
  21.             }
  22.        
  23.     }
  24.  
  25.  
  26. }
  27.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement