How to do sum of very big integer? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

How to do sum of very big integer?

If I am doing it with python execution time is greater than 5 seconds.In c i know we can use long long int. But is there any other way to do it? Please help

25th Apr 2020, 6:59 AM
Priyal Vyas
Priyal Vyas - avatar
6 Answers
+ 2
Rohit kumar Thank you very much!!! and I saw its implementation but do U know how much time does it take (Big O)?. Although I implement it in java using Big Integer class but it takes more time for large number.I will soon post that solution in java. https://code.sololearn.com/c2pZ3v8DQVuD/?ref=app
26th Apr 2020, 3:11 PM
Priyal Vyas
Priyal Vyas - avatar
+ 2
visph THANK YOU! ! I found the right algorithm(I wanted to calculate Fibonacci series of modulo m of very big integer.The algorithm for that is using pisano period ).I got your point. https://code.sololearn.com/c3IupR9r7IXj/?ref=app
26th Apr 2020, 3:40 PM
Priyal Vyas
Priyal Vyas - avatar
+ 1
You can do by using bit operations store the two numbers in binary format in arrays and then add by basic bit operations i.e. using carry and sum counter.
25th Apr 2020, 7:48 AM
Rohit kumar
Rohit kumar - avatar
+ 1
C is a compiled language. Python is an interpreted one. Execution time will ever be in favour of former (with equivalent algorithm), but ease of use of later will ever win ^^
25th Apr 2020, 9:29 PM
visph
visph - avatar
+ 1
Simple by adding them into each other 😉🤣
26th Apr 2020, 12:49 PM
CiPher
CiPher - avatar
0
CiPher I think u can hack NASA with Ur logic 😂😂😂.
26th Apr 2020, 3:06 PM
Priyal Vyas
Priyal Vyas - avatar