Question 1

x <- 1.1
a <- 2.2
b <- 3.3

# a.
z <- x^(a^b)
print(z)
## [1] 3.61714
# b.
z <- (x^a)^b
print(z)
## [1] 1.997611
# c.
z <- 3*x^3 + 2*x^2 + 1
print(z)
## [1] 7.413

Question 2

# a.
c(seq(1,8),seq(7,1))
##  [1] 1 2 3 4 5 6 7 8 7 6 5 4 3 2 1
# b.
rep(x=seq(1,5),times=seq(1,5))
##  [1] 1 2 2 3 3 3 4 4 4 4 5 5 5 5 5
# c. 
rep(x=seq(5,1),times=seq(1,5))
##  [1] 5 4 4 3 3 3 2 2 2 2 1 1 1 1 1

Question 3

cartesian <- runif(2)

polar <- c((((cartesian[1])^2 + (cartesian[2])^2)^.5),(atan(cartesian[2]/cartesian[1])))
print(polar)
## [1] 0.9523696 1.2949955

Question 4

queue <- c("sheep","fox","owl","ant")

# a. serpent arrives and gets in line
queue <- c(queue,"serpent")
print(queue)
## [1] "sheep"   "fox"     "owl"     "ant"     "serpent"
# b. sheep enters the ark
queue <- queue[-1]
print(queue)
## [1] "fox"     "owl"     "ant"     "serpent"
# c.donkey arrives and cuts to the front
queue <- c("donkey",queue)
print(queue)
## [1] "donkey"  "fox"     "owl"     "ant"     "serpent"
# d. serpent leaves
queue <- queue[-length(queue)]
print(queue)
## [1] "donkey" "fox"    "owl"    "ant"
# e. owl leaves
queue <- queue[c(1,2,4)]
print(queue)
## [1] "donkey" "fox"    "ant"
# f. aphid arrives and goes in front of the ant
queue <- c(queue[1:2], "aphid", queue[3])
print(queue)
## [1] "donkey" "fox"    "aphid"  "ant"
# g. where is the aphid in line?
print(length(queue[-1]))
## [1] 3

Question 5

# not divisible by 2, 3, 7

num <- seq(1,100)
print(which(num%%2 !=0 & num%%3 !=0 & num%%7 !=0))
##  [1]  1  5 11 13 17 19 23 25 29 31 37 41 43 47 53 55 59 61 65 67 71 73 79 83 85
## [26] 89 95 97