# +++++++++++++++++++++++++
# +++ R BOOTCAMP UNIT 1 +++
# +++     SOLUTIONS     +++
# +++++++++++++++++++++++++
# + AUTHOR: David Dobolyi +
# +++++++++++++++++++++++++

# ----------
# Exercise 1
# ----------

# Write code for the following arithmetic operations:

# add 3 plus 2

3 + 2

# subtract 2 from 5

5 - 2

# multiply 5 by 6

5 * 6

# divide 7 by 8

7 / 8

# find the remainder of 13 divided by 5 as a whole number

13 %% 5

# raise 9 to the 3rd power

9 ^ 3

# raise -3 to the 9th power

(-3) ^ 9 # note: careful when raising negative values to a power!

# raise 2 to the power of 5 minus 2

2 ^ (5 - 2) # note: again, be careful with ambiguity (e.g., 2 ^ 5 - 2 [without parentheses] is not equivalent)

# find the square root of 30

sqrt(30)

# determine how many times 14 can be divided by 3 sans remainder

14 %/% 3

# ----------
# Exercise 2
# ----------

# Uncomment and debug the following line of code so that it returns the intended result of 1.75:

# ((5 * 3) - (2 * 4) / (3 + 1)
 
((5 * 3) - (2 * 4)) / (3 + 1)

# ----------
# Exercise 3
# ----------
 
# Add an argument to the log function below so that it returns a result of 2:
 
log(100, base = 10)