Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Recursions
- {
- class Program
- {
- static int gcd(int a, int b)
- {
- if (b == 0)
- {
- return a;
- }
- return gcd(b, a % b);
- }
- static int lcm(int a, int b)
- {
- return ((a * b) / gcd(a, b));
- }
- static void CountDown(int num)
- {
- if (num == 0)
- {
- return;
- }
- Console.WriteLine(num);
- CountDown(num - 1);
- }
- static void PrintDigits(int num)
- {
- if (num == 0)
- {
- return;
- }
- PrintDigits(num / 10);
- Console.Write(num % 10 + " ");
- }
- static decimal Factorial(int n)
- {
- if (n < 0)
- {
- throw new ArgumentException("Factroial is not defined for negative numbers!");
- }
- if (n == 0)
- {
- return 1;
- }
- return n * Factorial(n - 1);
- }
- static decimal FactorialI(int n)
- {
- decimal result = 1;
- for (int i = 1; i <= n; i++)
- {
- result *= i;
- }
- return result;
- }
- static long Fib(int n)
- {
- if (n <= 2)
- {
- return 1;
- }
- return Fib(n - 2) + Fib(n - 2);
- }
- static void PrintMirrorTriangles(int n)
- {
- if (n == 0)
- {
- return;
- }
- Console.WriteLine(new string('*', n));
- PrintMirrorTriangles(n - 1);
- Console.WriteLine(new string('#', n));
- }
- static void Main(string[] args)
- {
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement