Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions