Question: onsider the following code: mystery < - function ( x ) { if ( x = = 1 ) { return ( x ^ 2

onsider the following code:
mystery <- function(x){
if (x ==1){
return(x ^2)
} else {
return(x ^2+ mystery(x -1))
}
}
(a)(4 points) What is the value of the expression mystery(4)?
Answer:
(b)(6 points) In the space below, write a new version of this function mystery2() that
does the same task without using recursion.
2.(4 points) Which two of the four following lines of code are equivalent?
a. "hello" |> print()
b. x <- "hello" |> print()
c. print("hello")
d. print |> "hello"
Answer:

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!