# How to write a summation in Julian?

**URL:** <https://discourse.julialang.org/t/how-to-write-a-summation-in-julian/91346>\
**Category:** General Usage\
**Tags:** question, ijulia, sum\
**Created:** [December 7, 2022, 5:58am UTC](https://discourse.julialang.org/t/how-to-write-a-summation-in-julian/91346 "2022-12-07T05:58:37Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![xArcoirisXx](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/xarcoirisxx/32/44877_2.png) [@xArcoirisXx](https://discourse.julialang.org/u/xArcoirisXx)\
**Post date:** [December 7, 2022, 5:58am UTC](https://discourse.julialang.org/t/how-to-write-a-summation-in-julian/91346/1 "2022-12-07T05:58:37Z")

</div>

How to write and solve a summation in Julian?

---

<div class="post-metadata">

**Author:** ![Oscar\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oscar_smith/32/25343_2.png) [@Oscar\_Smith](https://discourse.julialang.org/u/Oscar_Smith)\
**Post date:** [December 7, 2022, 5:59am UTC](https://discourse.julialang.org/t/how-to-write-a-summation-in-julian/91346/2 "2022-12-07T05:59:25Z")

</div>

`sum`

---

<div class="post-metadata">

**Author:** ![xArcoirisXx](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/xarcoirisxx/32/44877_2.png) [@xArcoirisXx](https://discourse.julialang.org/u/xArcoirisXx)\
**Post date:** [December 7, 2022, 6:10am UTC](https://discourse.julialang.org/t/how-to-write-a-summation-in-julian/91346/3 "2022-12-07T06:10:48Z")

</div>

How do I add the, summation index, the first value, the last favor and of course the formula for the terms?

---

<div class="post-metadata">

**Author:** ![sylvaticus](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sylvaticus/32/203883_2.png) [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)\
**Post date:** [December 7, 2022, 6:51am UTC](https://discourse.julialang.org/t/how-to-write-a-summation-in-julian/91346/4 "2022-12-07T06:51:51Z")

</div>

e.g. `y = sum(i^2 for i in source)` or `sum(source[starti:step:endi])` ?

In a terminal, click `?` and `enter`. This will lead you to the help prompt where you can just type `sum` + `enter` to get the documentation (with examples) of the `sum` function.

---

<div class="post-metadata">

**Author:** ![DNF](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dnf/32/10191_2.png) [@DNF](https://discourse.julialang.org/u/DNF)\
**Post date:** [December 7, 2022, 7:26am UTC](https://discourse.julialang.org/t/how-to-write-a-summation-in-julian/91346/5 "2022-12-07T07:26:31Z")

</div>

> [@sylvaticus](#):
>
> In a terminal, click `]` and enter. This will lead you to the help prompt

That’s the package management prompt. Type `?` at the prompt to enter help mode.

---

<div class="post-metadata">

**Author:** ![kellertuer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kellertuer/32/220707_2.png) [@kellertuer](https://discourse.julialang.org/u/kellertuer)\
**Post date:** [December 7, 2022, 7:35am UTC](https://discourse.julialang.org/t/how-to-write-a-summation-in-julian/91346/6 "2022-12-07T07:35:49Z")

</div>

Welcome to Julia discourse!

I also find the docs quite helpful, where you can find more examples as well

[https://docs.julialang.org/en/v1/base/collections/#Base.sum](https://docs.julialang.org/en/v1/base/collections/#Base.sum)

---

<div class="post-metadata">

**Author:** ![sylvaticus](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sylvaticus/32/203883_2.png) [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)\
**Post date:** [December 7, 2022, 8:10am UTC](https://discourse.julialang.org/t/how-to-write-a-summation-in-julian/91346/7 "2022-12-07T08:10:18Z")

</div>

yup, corrected, tk
