Created
March 29, 2019 15:15
-
-
Save Semior001/b470a4d91c64ba96190124ed6c486ff8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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