# Use Sum while the summand is a function?

Posted 2 months ago
313 Views
|
3 Replies
|
1 Total Likes
|
 Mathematica 11.3.0.0 Windows 10 64Before posting a bug, I would like if anybody can verify:The following works o.k: Sum[Times @@ (IntegerDigits[i, 7] + 1), {i, 0, 10^6}] However if the Summand is a function we get some gibberish: fu[n_] := Times @@ (IntegerDigits[n, 7] + 1); Sum[fu[i], {i, 0, 10^6}] Interestingly, the following works: Sum[fu[i], {i, 1, 10^6}] 
3 Replies
Sort By:
Posted 2 months ago
 Sum can do this "procedurally", and the default method (Automatic) apparently does so when given the explicit summand. With the function form it only does the procedural when the number of terms is under a certain limit, by default 10^6. The two examples straddle this limit, hence the observed behavior. One can change this default as below. SetSystemOptions["SymbolicSumThreshold" -> 1000001]; fu[n_] := Times @@ (IntegerDigits[n, 7] + 1) Sum[fu[i], {i, 0, 10^6}] (* Out[49]= 14938433536 *)