Skip to content

Instantly share code, notes, and snippets.

@wekonu
Created August 19, 2021 05:33
Show Gist options
  • Select an option

  • Save wekonu/5695e56ae78dca3d4b3b6fc1ad9ca418 to your computer and use it in GitHub Desktop.

Select an option

Save wekonu/5695e56ae78dca3d4b3b6fc1ad9ca418 to your computer and use it in GitHub Desktop.

Revisions

  1. wekonu created this gist Aug 19, 2021.
    50 changes: 50 additions & 0 deletions Recursion3.cs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,50 @@
    using System.CodeDom.Compiler;
    using System.Collections.Generic;
    using System.Collections;
    using System.ComponentModel;
    using System.Diagnostics.CodeAnalysis;
    using System.Globalization;
    using System.IO;
    using System.Linq;
    using System.Reflection;
    using System.Runtime.Serialization;
    using System.Text.RegularExpressions;
    using System.Text;
    using System;

    class Result
    {

    /*
    * Complete the 'factorial' function below.
    *
    * The function is expected to return an INTEGER.
    * The function accepts INTEGER n as parameter.
    */

    public static int factorial(int n)
    {
    if (n < 2)
    return 1;

    return n * factorial(n - 1);
    }

    }

    class Solution
    {
    public static void Main(string[] args)
    {
    TextWriter textWriter = new StreamWriter(@System.Environment.GetEnvironmentVariable("OUTPUT_PATH"), true);

    int n = Convert.ToInt32(Console.ReadLine().Trim());

    int result = Result.factorial(n);

    textWriter.WriteLine(result);

    textWriter.Flush();
    textWriter.Close();
    }
    }