Hello All I have a method, which gives me the required number of Boxes based on number of devices it can hold.Currently i have implemented this logic using recursion
private uint PerformRecursiveDivision(uint m_oTotalDevices,uint m_oDevicesPerBox, ref uint BoxesRequired)
{
if (m_oTotalDevices< m_oDevicesPerBox)
{
BoxesRequired = 1;
}
else if ((m_oTotalDevices- m_oDevicesPerBox>= 0) && (m_oTotalDevices- m_oDevicesPerBox) < m_oDevicesPerBox)
{
//Terminating condition
BoxesRequired++;
return BoxesRequired;
}
else
{
//Call recursive function
BoxesRequired++;
return PerformRecursiveDivision((m_oTotalDevices- m_oDevicesPerBox), m_oDevicesPerBox, ref BoxesRequired);
}
return BoxesRequired;
}
Is there any better method to implement the same logic without using recursion. Cos this method is making my application very slow for cases when number of devices exceeds 50000.
Thanks in advance for your support Constant learner