You are on page 1of 1

public string DescomponerEnFactoresPrimos(int n)

{
string result = "";
DescomponerEnFactoresPrimos(n, 2, ref result);
return result;
}
private void DescomponerEnFactoresPrimos(int numero, int divisor, ref str
ing result)
{
if (numero == 1)
return;
if (numero % divisor == 0)
{
result += divisor + ",";
DescomponerEnFactoresPrimos(numero / divisor, divisor, ref result
);
}
else
DescomponerEnFactoresPrimos(numero, divisor + 1, ref result);
}

You might also like