Quick Questions: October 05, 2022

Hello! I'm posting in here because I assume I'm missing something obvious so this has got to be simple... if not I'll make a post.

While going through Project Euler I decided it might be fun (and possibly handy) to create a function capable of multiplying a huge array (thousands?) of possibly very long numbers (from one to hundreds of digits) together.

I found a way to handle multiplying two long numbers together nmore efficiently (Karatsuba with numbers passed as strings--I am too much of a beginner for Fourier transforms), but it can't handle the case of a very short number multiplied by a very long one, for example 7 * 4387562385764087628436509[insert many digits here]--the Karatsuba algorithm videos and pages I found all seem to set up the base case as "if either num < 10, then multiply directly" but that second number is too large for even the largest numeric data type.

So I feel like I'm back to square one having to test if the number is too large first (adds operations) and then using a "SumOfLargeNumbers" function to handle this as a sequence of additions (adds more operations).

My gut tells me there's a better way to do this and I'm adding unnecessary complications. Could I have a hint as to what else is out there for this type of case, please? I don't mind getting reading suggestions since I enjoy the process of figuring this stuff out.

Thanks!

/r/math Thread