Click here to Skip to main content
15,890,506 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Program to calculate the prime number or not for 2^n+1 where n is 3-digit number?


I tried to write the program but i am unable to store the large values for ex:2^123.

I declared the variable as long but i am unable to store the values.

Can u please suggest which datatype must use to store such a long number.


if u have any code for calculating this program please send the example code.

Thanking you
gowtham
Posted

1 solution

In C# the long datatype is a signed integer with 64 bit size, then it could hold up to 2^63-1.
If you use unsigned long you will be able to hold numbers up to 2^64-1.

To hold numbers greater than these, you should use some specific class or library. You can start reading this article: C# BigInteger Class[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900