5
$\begingroup$

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.

$\endgroup$
  • $\begingroup$ 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. $\endgroup$ – yarchik Feb 21 at 17:12
6
$\begingroup$

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]]]

enter image description here

|improve this answer|||||
$\endgroup$
4
$\begingroup$

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]

(start with a number of multiples smaller than 10k) then

17 Range[10000]

then

IntegerDigits/@(17 Range[10000])

and so for the

|improve this answer|||||
$\endgroup$
4
$\begingroup$

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

enter image description here

|improve this answer|||||
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.