Handling "Big" Integers in C#
Posted
by priyanka.sarkar
on Stack Overflow
See other posts from Stack Overflow
or by priyanka.sarkar
Published on 2009-06-06T15:26:46Z
Indexed on
2010/05/09
21:08 UTC
Read the original article
Hit count: 308
How do I handle big integers in C#?
I have a function that will give me the product of divisors:
private static int GetDivisorProduct(int N, int product)
{
for (int i = 1; i < N; i++)
{
if (N % i == 0)
{
Console.WriteLine(i.ToString());
product *= i;
}
}
return product;
}
The calling function is GetDivisorProduct(N, 1)
If the result is bigger than 4 digits , I should obtain only the last 4 digits. ( E.g. If I give an input of 957, the output is 7493 after trimming out only the last four values. The actual result is 876467493.).
Other sample inputs: If I give 10000, the output is 0.
The BigInteger
class has been removed from the C# library!
How can I get the last four digits?
© Stack Overflow or respective owner