Summation without loops

后端 未结 4 955
孤街浪徒
孤街浪徒 2021-01-21 15:11

I have following double summation: ∑10,i=1 ∑i,j=1 (i^5/(10+j^i))

I am quite lost with this exercise, I tried the following code but I it returns an error although giving

4条回答
  •  我在风中等你
    2021-01-21 15:38

    You could expand all the possible i/j combinations and then sum up all the terms

    i <- 1:10
    ii <- rep(i, i)
    jj <- unlist(sapply(i, function(x) seq(1,x)))
    sum(ii^5/(10+jj^ii))
    # [1] 20835.22
    

提交回复
热议问题