I am testing a matrix if it has a prime number in every line.
The MR means that it should use the Miller Rabin algorithm. If its false it simply tries the divisors up to sqrt(n). Vansor is true if it has found a prime in every checked row, vanoszlop is true if it has found a prime in the actually checked row.
My question is: Is it possible to save the memory by not creating both the int and BigInteger values only if the tryParse is true? I mean something like
if (int.tryParse(akt, out new int szam))
Is something like this possible? (and how much memory does a BigInteger take when its not signed?)
akt = Console.ReadLine();
int szam; BigInteger szambig;
if (int.TryParse(akt, out szam))
{
if (MR) {
if (MilRab(szam))
{ vansor = true; vanoszlop = true; } }
else if (Prim(szam))
{ vansor = true; vanoszlop = true; }
}
else if (BigInteger.TryParse(akt, out szambig))
{
if (MR) {
if (MilRab(szam))
{ vansor = true; vanoszlop = true; } }
else if (Prim(szam))
{ vansor = true; vanoszlop = true; }
}