Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Diagnostics;
- using System.Numerics;
- namespace Tests
- {
- class Program
- {
- private static BigInteger silnia(int i)
- {
- BigInteger result = 1;
- for (int x = 1; x <= i; x++)
- {
- result *= x;
- }
- return result;
- }
- public static void Main(string[] args)
- {
- Console.Write("Wprowadź liczbę, której silnię pragniesz policzyć: ");
- int n = int.Parse(Console.ReadLine());
- Stopwatch watch = new Stopwatch();
- watch.Start();
- BigInteger resultF = silnia(n);
- TimeSpan factTime = watch.Elapsed;
- watch.Restart();
- string resultAsString = resultF.ToString();
- TimeSpan convTime = watch.Elapsed;
- Console.WriteLine("Wynik: {0}", resultAsString);
- Console.WriteLine("Czas obliczeń: {0} sekund", factTime.TotalSeconds);
- Console.WriteLine("Czas konwersji: {0} sekund", convTime.TotalSeconds);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement