optimized by caching the sum_multiplicities for 9-digit numbers