## Problem 1 using a for loop
sum <- 1
for(i in 1:13){
sum=sum*i
}
print(sum)
## [1] 6227020800
## using a while loop 

sum <- 1
x <-1
while(x<14){
  sum =sum*x
  x=x+1
}
print(sum)
## [1] 6227020800
## Problem 2 A Numeric Vector 

xvect <- seq(from=10,to=50,by=5)
print(xvect)
## [1] 10 15 20 25 30 35 40 45 50
## Problem 3 Function 

lines <- function(x1,y1,x2,y2)
{
  distance <-((x2-x1)^2)+((y2-y1)^2)
  dist=sqrt(distance)
  print(sprintf("The distance is %s",dist))
  
  ## calculate the slope
  slope <- (y2-y1)/(x2-x1)
  print(sprintf("The slope is %s",slope))
  
  ## calculate the y intercept
  y_intercept <- y1 - (slope * x1)
  print(sprintf("the y-intercept is %s",y_intercept))
}

lines(1,2,4,6)
## [1] "The distance is 5"
## [1] "The slope is 1.33333333333333"
## [1] "the y-intercept is 0.666666666666667"