Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Long Long Int in python

Tags:

python

I have a task to calculate a sum of very big integers. the sum could be over the limit of max value of int. I'd like to use long long int type like in c to prevent this. python is dynamic type language. but there must be someway to declare this long long int type. help me to declare long long int type in python. thanks

like image 781
Derek Jin Avatar asked Oct 27 '25 05:10

Derek Jin


1 Answers

You don't need to.

>>> sum([
...     1243926478235632786572938657832682396538279658237956832976482375678239659782365,
...     23590237589734985720423803758031640192748372946743079324780137092704730297409327409237409237432,
... ])
23590237589734986964350281993664426765687030779425475863059795330661563273891703087477069019797

Python has arbitrary-size integers, that can become way larger than C's long long.

like image 121
L3viathan Avatar answered Oct 29 '25 18:10

L3viathan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!