# Can't make this fraction

I want to create a formula for summing an arithmetic sequence in which the first term is 'a1' and the nth term is 'an' through the following formula.

${{S_n}}$ = \frac{n(${{a_1}}$+${{a_n}}$)}{2}


However, the result is as follows.

How could I solve this problem? I am currently working on overleaf.

I'm worried that since my native language is not English and I am new to LaTeX, my question may seem a bit odd.

• $S_n = \frac{n(a_1+a_n)}{2}$ is the correct input. See What are good learning resources for a LaTeX beginner? Sep 5, 2022 at 22:13
• Welcome to TeX.SX. To typeset mathematical expressions, don't enter and leave "math mode" for each symbol. $ at the beginning and again at the end. Also, you don't need so many braces: $S_n = \frac{n(a_1+a_n)}{2}$ Sep 5, 2022 at 22:14 • Welcome. // The problem seems to be that you switch the math mode on and off several times. In running text you type$ formulas $, i.e. just 2$, just like opening and closing braces. Or for longer equation you start math mode by [ and end it by ] . See related links to the right for examples. Sep 5, 2022 at 22:16
• A different issue: Your description of the summation sounds more to me like $S_n = \frac{n(a_1 + \ldots + a_n)}{2}$ with an ellipsis representing a₂, a₃, etc., but I might be misunderstanding. Sep 5, 2022 at 22:17
• @frabjous $S_n = a_1+\dots+a_n = n(a_1+a_n)/2$. Sep 6, 2022 at 2:08

\documentclass{article}
$S_{n}= \frac{n(a_1 + a_n)}{2}$

• dont use $$ in latex Sep 5, 2022 at 22:21 • if we shouldn't use it, why was the$$... placed in latex? Sep 5, 2022 at 22:28