Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2014
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.88 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 Factorial
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             Console.Write("Введите число: ");
  14.             int number = int.Parse(Console.ReadLine());
  15.             Factorial(number);
  16.             string output = String.Format("Факториал вашего числа равен {0}", Factorial(number));
  17.             Console.WriteLine(output);
  18.             Console.ReadLine();
  19.         }
  20.  
  21.         public static double Factorial(double i)
  22.         {
  23.  
  24.             if (i == 0)
  25.             {
  26.                 return 1;
  27.             }
  28.             else
  29.             {
  30.                 double returnNumber = i * Factorial(i - 1);
  31.                 return returnNumber;
  32.             }
  33.         }
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement