I have an input called divisibleBy
which is an integer. I want to get all the possible numbers that it is divisible with except itself.
For example:
var divisibleBy = 16;
the output should be "2,4,8". "16" was not included because it is equal to itself. Now i want it to be a list but without using for loop. It could be using a LINQ or whats your recommended. since there is a possibility that the divisbleBy
can be greater than 1000 so looping would cause performance issue.
heres my current code using loop
var list = new List<int>();
for (var cols = divisibleBy - 1; cols > 0; cols--)
{
if (divisibleBy % cols != 0) continue;
list.Add(cols);
}