diff --git a/LeoCorpLibrary/Extensions/IntExtensions.cs b/LeoCorpLibrary/Extensions/IntExtensions.cs index cb02bc4..1f0709a 100644 --- a/LeoCorpLibrary/Extensions/IntExtensions.cs +++ b/LeoCorpLibrary/Extensions/IntExtensions.cs @@ -22,6 +22,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ using System; +using System.Collections.Generic; namespace LeoCorpLibrary.Extensions { @@ -166,5 +167,20 @@ public static double ConvertSizeUnitToPetabyte(this int i, UnitType unitType) default: return i; // Convert and return value } } + + public static int[] GetDivisors(this int number) + { + List ds = new List(); // Create a list + + for (int i = 1; i <= number; i++) + { + if (number % i == 0) // Check if the number is a divisor + { + ds.Add(i); // Add divisor + } + } + + return ds.ToArray(); + } } }