forked from dotnet/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
43 lines (36 loc) · 826 Bytes
/
Copy pathProgram.cs
File metadata and controls
43 lines (36 loc) · 826 Bytes
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
using System;
namespace Hello
{
class Program
{
static void Main(string[] args)
{
if (args.Length > 0)
{
Console.WriteLine($"Hello {args[0]}!");
}
else
{
Console.WriteLine("Hello!");
}
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;
}
}
}