Skip to content

Commit 8f67724

Browse files
committed
Rearranged the code and added comments
1 parent 0178e09 commit 8f67724

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

Algorithms/Numeric/GreatestCommonDivisor.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
1-
namespace Algorithms.Numeric
1+
/***
2+
* Euclidean Algorithm to find the greatest common divisor of two numbers.
3+
*
4+
*/
5+
6+
7+
namespace Algorithms.Numeric
28
{
39
public static class GreatestCommonDivisor
410
{
11+
/// <summary>
12+
/// Finds and returns the greatest common divisor of two numbers
13+
/// </summary>
514
public static uint FindGCD(uint a, uint b)
615
{
716
if (a == 0)
@@ -24,6 +33,9 @@ public static uint FindGCD(uint a, uint b)
2433
return _b;
2534
}
2635

36+
/// <summary>
37+
/// Determines given two numbers are relatively prime
38+
/// </summary>
2739
public static bool IsRelativelyPrime(uint a, uint b)
2840
{
2941
return FindGCD(a, b) == 1;

MainProgram/AlgorithmsTests/GreatestCommonDivisorTest.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
using System;
2-
using System.Collections.Generic;
3-
using System.Diagnostics;
4-
using System.Linq;
5-
using System.Text;
6-
using System.Threading.Tasks;
2+
3+
using Algorithms.Numeric;
4+
75

86
namespace C_Sharp_Algorithms.AlgorithmsTests
97
{
@@ -26,7 +24,7 @@ public static void DoTest()
2624

2725
for (int i = 0; i < testNumbers.GetLength(0); i++)
2826
{
29-
uint gcd = Algorithms.Numeric.GreatestCommonDivisor.FindGCD(testNumbers[i, 0], testNumbers[i, 1]);
27+
uint gcd = GreatestCommonDivisor.FindGCD(testNumbers[i, 0], testNumbers[i, 1]);
3028

3129
if (Assert(testNumbers[i,0], testNumbers[i,1], gcd))
3230
{

0 commit comments

Comments
 (0)