I want processing large numbers with 10k+ digits, so I use tuples, because integer type cannot be used (precision of number is important, because sum of digits). There are only 2 unique digits, 9 and 0.
First condition: Modulo of sum of digits with 999 is 0.
Second condition: It is large integer number, so first digit cannot be 0.
Last condition: Last digit is 0.
My solution is:
from itertools import product
L = [10000,11000,12000]
for M in L:
for i in product([0, 9], repeat=M):
if i[0] != 0 and i[-1] == 0:
s = sum(i)
if s % 999 == 0:
print (s)
Is possible count number of generated values with these conditions? Is possible change solution/another solution(s) for reduce time of generating expected output, e.g. generate only digits with sum of digits is more like 999? I am thinking about Decimal, but here is problem with sum of digits. Order of generated numbers (tuples, arrays) is not important.
It is so huge tuples, so problematic easy testing.I try create some sample (not idea if useful):
for i in product([9, 0], repeat=20):
if i[0] != 0 and i[-1] == 0:
s = sum(i)
if s % 99 == 0:
print (i, s)