-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
55 lines (46 loc) · 1.21 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
using System;
namespace Progress
{
class Program
{
static void Main(string[] args)
{
if(args.Length > 0)
{
Console.WriteLine($"Hello {args[0]}!");
}
else
{
Console.WriteLine("Hello World!");
}
Console.WriteLine("Performing time consuming task...");
using(var progress = new ProgressBar())
{
for(int i = 0; i < 100; i++)
{
progress.Report((double) i / 100);
System.Threading.Thread.Sleep(200);
}
}
Console.WriteLine("Task is done!");
Console.WriteLine("Fibonacci numbers 1-15:");
for(int i = 0; i < 15; i++)
{
Console.WriteLine($"{i+1}: {FibonacciNumber(i)}");
}
}
static int FibonacciNumber(int n)
{
int a = 0;
int b = 1;
int tmp;
for(int i = 0; i < n; i++)
{
tmp = a;
a = b;
b += tmp;
}
return a;
}
}
}