Question 1

# Question 1: Write a loop that calculates 13-factorial. 
#Bonus - try to do it two different ways (for example
#use a for loop and a while loop). Do not use the standard factorial function. The goal is to learn
#about how R uses loops.

# For-loop version:
a<-1
for (i in 1:13) {
  a<-a*i
}

print(a)
## [1] 6227020800
#While-loop version:
b<-13
product<-1
while (b>0) {
  product<-product*b
  b<-b-1
}

print(product)
## [1] 6227020800

Question 2

# Question 2: Show how to create a numeric vector that contains the sequence from 10 to 50 by 5.
x<-seq(10,50,5)
x
## [1] 10 15 20 25 30 35 40 45 50

Question 3

# Question 3: Create the function “lines” that takes two x,y points and calculates three things: the
# distance between those two points, the slope and the y intercept. The function should allow
# you to input both x and y values and give you the three answers.
lines<-function(x1,y1,x2,y2) {
  distance<-sqrt((x2-x1)**2+(y2-y1)**2)
  slope<-(y2-y1)/(x2-x1)
  intercept<-y1-(slope*x1)
  print(distance)
  print(slope)
  print(intercept)
}