here is sample code
public static decimal factorization(decimal num, decimal factor)
{
if (num == 1)
{
return 1;
}
if ((num % factor)!= 0)
{
while(num% factor != 0)
{
factor++;
}
}
factors.Add(factorization(num / factor, factor));
return factor;
}
Note : I have initialize factors as global.
Above code will work fine for sample inputs 90 , 18991325453139 but will not work for input 12745267386521023 ... so how can I do that ? How can I achieve this efficiently ... I know recursive call will consume memory that's why I have checked the last input using without recursion .. But its not working too