Given two very large numbers a
and b
where a < b
, the problem is to find the following sum:
a + (a + 1) + (a + 2) + ... + (b - 2) + (b - 1) + b
The numbers a
and b
can be very very large (can contain millions of digits).
As these are very large numbers, programming languages cannot find the sum using integer data types. So, the only option is to use strings.
What is the most efficient way to do so?