New answers tagged

2 votes

Get cumulative sums in a list without using a for loop

Cumulate[f_, r_] := Module[{n = 1}, Prepend[1] @ Map[n += f[#] &] @ r] f[x_] := x^2 Cumulate[f, Range[2, 50, 2]] {1, 5, ...
eldo's user avatar
  • 69.5k
9 votes

Get cumulative sums in a list without using a for loop

f[x_] := x^2 Accumulate[f /@ {1}~Join~Range[2, 50, 2]] or FoldList[#1 + f[#2] &, f[1], Range[2, 50, 2]] {1, 5, 21, 57, ...
Syed's user avatar
  • 53.6k
1 vote

Convergent Taylor series unrecognized by Sum

Indeed, FactorialPower[n, k]/(k!) == Binomial[n, k] // FunctionExpand True However, the above result is only generic: ...
user64494's user avatar
  • 26.3k
1 vote

NSum with variable sitting inside

Notice that your term can be written as $s_k=a_k+b_k\delta$, and so we can sum the $\alpha_k$ separately from the $\beta_k$ (numerically) as they are independent of $\delta$: $$ \sum_{k=2}^{\infty}s_k=...
Roman's user avatar
  • 47.5k
6 votes

Mathematica failing to evaluate sum

...
Bob Hanlon's user avatar
  • 158k
5 votes
Accepted

Mathematica stuck for more than 12 hours on getting numerical value

A big caveat emptor for the stuff below, as I'm playing fast and loose with the precision, but it seems to work. Defining the function numerically as follows ...
Hans Olo's user avatar
  • 1,843
2 votes

Module that finds the sum of digits of any given positive integer

f = # /. x_ :> Plus @@ ToExpression@Characters[ToString[Abs@x]] &; f@2147 14 f /@ {-4, 0, 4, 44, 444} {4, 0, 4, 8, ...
E. Chan-López's user avatar
3 votes

Module that finds the sum of digits of any given positive integer

f = Total @ ToExpression @ DeleteCases["-"] @ Characters @ ToString @ # &; f @ 2147 14 ...
eldo's user avatar
  • 69.5k
3 votes

Module that finds the sum of digits of any given positive integer

Another way: NumberDecompose[2525, {1000, 100, 10, 1}]//Total (* 14 *) Or ...
user1066's user avatar
  • 18.2k
1 vote

Sum of list elements in a range

Using ArrayReduce and Partition: ...
Syed's user avatar
  • 53.6k
3 votes

Sum of list elements in a range

data = Range[20]; Using MovingMap: ...
E. Chan-López's user avatar
1 vote

Sum of list elements in a range

data = Range[20]; Using SequenceCases Total @ SequenceCases[data, {Repeated[_, {5}]}] {34, ...
eldo's user avatar
  • 69.5k

Top 50 recent answers are included