# Among the first 10,000 multiples of 17

Hello I'm new with Mathematica and I can't find a way where I can do this condition.

Among the first 10,000 multiples of 17 how many have the sum of their digit multiple of 17?

The part for the digit I should be able to do it but the first part is hard for me. Thanks for the future help.

• Wellcome here! You need to generate 10,000 multiples of 17 and then select the ones that fulfill your condition. The first task can be done with Table. You generate digits with IntegerDigits. Mod computes the reminder and can tell you whether they are multiples of 17. – yarchik Feb 21 at 17:12

I am curious what do you need this problem for? You can write a function for arbitrary numbers:

multSUM[n_,m_]:=Select[Table[m k,{k,n}],Divisible[Total[IntegerDigits[#]],m]&]


Then for exactly your problem, 100 first results:

Multicolumn[multSUM[10^4,17][[;;100]]]


This works (at least to the limited extent that I have tested it) ...

17 Flatten[Position[Total/@IntegerDigits/@(17 Range[10000]),17]]


To understand it, pick it apart from the inside out, ie first figure out

Range[10000]


17 Range[10000]


then

IntegerDigits/@(17 Range[10000])


and so for the

Reap and Sow can be used. For example,

r = Reap[Table[
Sow[17 j, IntegerDigits[17 j] // Total], {j, 1, 10000}], 17][[2,
1]];


This yields 452 integers. Showing first 100:

Partition[r[[1 ;; 100]], 10] // Grid