-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathProgram.cs
55 lines (51 loc) · 1.38 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;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace GitHubTestProject
{
public class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello Github!");
Console.WriteLine("Please complete the following functions and initate a pull request.");
}
/// <summary>
/// Tests if a given number is a prime
/// </summary>
/// <param name="n"></param>
/// <returns></returns>
public static bool IsPrime(int n)
{
for (int i = 2; i <= Math.Sqrt(n); i++)
if (n % i == 0)
return false;
return true;
}
/// <summary>
/// Sorts a given integer array
/// </summary>
/// <param name="a">An integer array</param>
public static void Sort(int[] a)
{
int n = a.Length;
int min, minI;
for (int i = 0; i < n; i++)
{
minI = i;
min = a[i];
for (int j = i; j < n; j++)
{
if (a[j] < min)
{
minI = j;
min = a[j];
}
}
a[minI] = a[i];
a[i] = min;
}
}
}
}