-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathProgram.cs
58 lines (51 loc) · 1.48 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
56
57
58
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)
{
if (n == 2)
return true;
if (n % 2 == 0 || n == 1)
return false;
for (int i = 3; i < Math.Sqrt(n); i = i + 2)
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[] arr)
{
int temp = 0;
for (int write = 0; write < arr.Length; write++)
{
for (int sort = 0; sort < arr.Length - 1; sort++)
{
if (arr[sort] > arr[sort + 1])
{
temp = arr[sort + 1];
arr[sort + 1] = arr[sort];
arr[sort] = temp;
}
}
}
}
}
}