Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please use R to generate the answer. Thank you. Control flow and functions are a basic aspect of every computer language. In R you can

image text in transcribedPlease use R to generate the answer. Thank you.

Control flow and functions are a basic aspect of every computer language. In R you can use loops with the following syntax: for (A in B) { C}. Here, if A is a variable name, and 'B' is a vector and 'C' is an expression, then the expression will be evaluated once for each element of the vector 'B' (and the variable A may be used in the expression 'C' and the value of A will walk through all elements of the vector B). You can define and call functions with the syntax A = function(B) { C; return(D); }. In this code, A is now a function that takes one argument, and 'C' and 'D' are expressions that may refer to 'B'. You can call the function Ausing code like A(7)?. Here's an example: A = function(B) { C = B + 7; return(C) } A (22) The result of A(22) should be 29, does that make sense? Question 5a, (3 points): Fibonacci numbers. The first two Fibonacci numbers are both 1 (fi = $2 = 1). The n-th Fibonnaci number fn (for n > 2) is fn = fn-1 + fn-2. Write R code to compute the sum of the first 20 Fibonacci numbers. You may use recursive functions, or you may use Cramer's rule for linear equations. Provide the sum of the first 20 Fibonacci numbers. Question 5b, (1 point): Provide the R code you used to compute the previous answer. Question 5c, (1 bonus point): Provide an estimate of the logarithm of the sum of the first one million Fibonacci numbers, in scientific notation with 4 digits in the significand

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

Recommended Textbook for

Secrets Of Analytical Leaders Insights From Information Insiders

Authors: Wayne Eckerson

1st Edition

1935504347, 9781935504344

More Books

Students also viewed these Databases questions

Question

java 8:51 7 ill? ( pro 1.png (( 8:51 7 ill? ( pro 1.png ((

Answered: 1 week ago

Question

Describe the Indian constitution and political system.

Answered: 1 week ago

Question

Explain in detail the developing and developed economy of India

Answered: 1 week ago

Question

Problem: Evaluate the integral: I = X 52+7 - 1)(x+2) dx

Answered: 1 week ago

Question

What is gravity?

Answered: 1 week ago

Question

What is the Big Bang Theory?

Answered: 1 week ago

Question

LO2 Compare three types of individual incentives.

Answered: 1 week ago