Advertisement
dakata

Recursion

Feb 19th, 2016
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.34 KB | None | 0 0
  1. using System;
  2.  
  3. namespace factoriel
  4. {
  5.     class Program
  6.     {
  7.         static void Main()
  8.         {
  9.             Console.WriteLine(factoriel(10));
  10.         }
  11.         static int factoriel(int n)
  12.         {
  13.             if(n == 2)
  14.             {
  15.                 return 2;
  16.             }
  17.                 return factoriel(n - 1) * n;
  18.            
  19.         }
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement