Hi all,

I plot a series manually, then I thought I want to learn to use `for loop`

/ `function`

. I don’t know which one is better.

The series are famous:

a_{n} = \frac{(-1)^{n}}{n}

For n even it will be \frac{1}{n}

For n odd it will be - \frac{1}{n}

When I try this code below I am unable to use `&&`

I can’t use `i`

and `j`

, moreover the graph does not even show up:

```
using Plots, LaTeXStrings
gr()
scatter([1], [1], color = "red", markersize = 4,
legend=:outerright, label="", framestyle=:zerolines,
xlims = (0,30), xticks = 0:1:30,
ylims = (-2,2), yticks = -2:4:2,
linestyle=:dot, size=(720, 360))
for i in 1:2:33
scatter!([i], [(-1)^(i)/i], color = "red", label="", markersize = 4)
end
for i in 2:2:33
scatter!([i], [(-1)^(i)/i], color = "red", label="", markersize = 4)
end
```

This is the manual code:

```
using Plots, LaTeXStrings
gr()
a, b = -10, 10
h(x) = 1
plot(h, a, b; legend=:outerright, label="", framestyle=:zerolines,
xlims = (0,10), xticks = 0:1:10,
ylims = (-2,2), yticks = -2:4:2,
linestyle=:dot, size=(720, 360))
plot!([1,0],[1,1], label="", linecolor=:green, linestyle=:dash)
plot!([2,0],[2,2], label="", linecolor=:green, linestyle=:dash)
plot!([3,0],[3,3], label="", linecolor=:green, linestyle=:dash)
plot!([4,0],[4,4], label="", linecolor=:green, linestyle=:dash)
scatter!([1], [-1], color = "red", label=L"a_{n}=\frac{1}{n}", markersize = 4)
scatter!([2], [1/2], color = "green", label=L"a_{n}=- \frac{1}{n}", markersize = 4)
scatter!([3], [-1/3], color = "red", label="", markersize = 4)
scatter!([4], [1/4], color = "green", label="", markersize = 4)
scatter!([5], [-1/5], color = "red", label="", markersize = 4)
scatter!([6], [1/6], color = "green", label="", markersize = 4)
scatter!([7], [-1/7], color = "red", label="", markersize = 4)
scatter!([8], [1/8], color = "green", label="", markersize = 4)
scatter!([9], [-1/9], color = "red", label="", markersize = 4)
scatter!([10], [1/10], color = "green", label="", markersize = 4)
annotate!([(5.1,0.2, (L"\mathbb{R}", 10, :black)),
(0.3,4.82, (L"\mathbb{R}", 10, :black))])
```