---
title: "Warm-up worksheet #2: Solutions"
author: "Milica Cudina"
date: "`r Sys.Date()`"
output: pdf_document
---
<!-- The author of this template is Dr. Gordan Zitkovic.-->
<!-- The code chunk below contains some settings that will  -->
<!-- make your R code look better in the output pdf file.  -->
<!-- If you are curious about what each option below does, -->
<!-- go to https://yihui.org/knitr/options/ -->
<!-- If not, feel free to disregard everything ...  -->
```{r echo=FALSE, warning=FALSE, include=FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  fig.align="center",
  fig.pos="t",
  strip.white = TRUE
)
```
<!-- ... down to here. -->

---

Create an `R`-notebook which prints out the answers to the following problems. All of your work and calculations **must** be done in `R`.

# Arithmetic 
## Problem 1. 
Multiply 7 by 21. 
```{r}
7*21
```

## Problem 2. 
Find the square root of $\pi$
```{r}
sqrt(pi)
```

## Problem 3. 
Calculate $e^3$
```{r}
exp(3)
```

## Problem 4. 
Find the fourth root of 1024.
```{r}
(1024)^(1/4)
```

## Problem 5. 
Calculate the natural logarithm of 5.
```{r}
log(5)
```

# Variables and vectors
## Problem 6.  
Assign the value 2 to variable `a` and  the value 3 to variable `b`; print out their ratio
```{r}
a=2
b=3
a/b
```

## Problem 7.
Set the vector `v` to be the numbers between -1 and 8 (inclusive); set the vector `w` to be the first 10 natural numbers; what do you get when you multiply `v` by `w`?
```{r}
v=-1:8
w=1:10
v*w
```

# Loops
## Problem 8. 
Write and execute a chunk of code which calculates and prints out the sum of squares of the first $n$ natural numbers for $n=1, 2, \dots, 25$. 
```{r}
for(i in 1:25){
  print(sum((1:i)^2))
}
```

