-
Notifications
You must be signed in to change notification settings - Fork 0
/
Number.cs
35 lines (31 loc) · 1.01 KB
/
Number.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
using System;
using System.Collections.Generic;
namespace Numbers
{
///
/// Class for several number operations
///
public class NumberOperations
public class NumberOperations
{
/// <summary>
/// To find the smallest number among a given set of numbers
/// Assumption: list will always contain at least one number
/// </summary>
/// <param name="listOfNumbers"> List of numbers</param>
/// <returns> Returns the smallest number from the list</returns>
public static int FindSmallestNumberFromListOfNUmbers(List<int> listOfNumbers)
{
// start with the first number as reference to compare
int smallestNumber = listOfNumbers[0];
for (int i = 1; i < listOfNumbers.Count; i++)
{
if (listOfNumbers[i] < smallestNumber)
{
smallestNumber = listOfNumbers[i];
}
}
return smallestNumber;
}
}
}