Skip to content

Instantly share code, notes, and snippets.

@Semior001
Created March 29, 2019 15:15
Show Gist options
  • Save Semior001/b470a4d91c64ba96190124ed6c486ff8 to your computer and use it in GitHub Desktop.
Save Semior001/b470a4d91c64ba96190124ed6c486ff8 to your computer and use it in GitHub Desktop.
using System;
using System.Threading;
namespace Quiz29March
{
public class Task2
{
public static void Main(string[] args)
{
int n = Int32.Parse(Console.ReadLine());
new Thread(() =>
{
Factorial(n);
}).Start();
new Thread(() =>
{
Sum(n);
}).Start();
}
public static void Factorial(long n)
{
long result = 1;
for (long i = 2; i <= n; i++)
{
result *= i;
Console.WriteLine("Считаю факториал");
Thread.Sleep(500);
}
Console.WriteLine("Факториал: " + result);
}
public static void Sum(long n)
{
long result = 1;
for (long i = 2; i <= n; i++)
{
result += i;
Console.WriteLine("Считаю сумму");
Thread.Sleep(500);
}
Console.WriteLine("Сумма: " + result);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment