1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
lys-0071 [83]
3 years ago
8

The Fibonacci sequence 1, 1, 2, 3, 5, 8, 13, 21…… starts with two 1s, and each term afterward is the sum of its two predecessors

. Please write a function, Fib(n), which takes n as the input parameter. It will return the n-th number in the Fibonacci sequence. Using R, the output for Fib(9) should give only the 9th element in the sequence and not any of the previous elements. Please Help :)
Engineering
2 answers:
Novay_Z [31]3 years ago
5 0

9th value is 34

Explanation:

R or Fib (n) function is given by: (n - 1) + (n - 2), where n is the number in the Fibonacci sequence .

Hence, fib (9) = (9 - 1) + (9 - 2)

                      = 8th value + 7th value on the sequence summed together  

<em>Fibonacci sequence: 1, 1, 2, 3, 5, 8, 13, 21.</em><em> </em>The 8th value is 21 and the 7th value is 13.  

R = (n - 1) + (n - 2)

R (9) 0r Fib (9) = 21 + 13

           = 34

Olin [163]3 years ago
5 0
<h2>Answer:</h2>

  #Create a function Fib to return the nth term of the fibonacci series

  #Method header declaration

   Fib <- function(n)  {

 

   #when n <= 1, the fibonacci number is 1

   #hence return 1

   if (n <= 1)

           return(1)

   #when n = 2, the fibonacci number is 1

   #hence return 1

   else if (n == 2)

            return(1)

   

   #at other terms, fibonacci number is the sum of the previous two

   #numbers.

   #hence return the sum of the fibonacci of the previous two numbers

   else

           return( Fib(n-1) + Fib(n-2))

   }    #End of method.

============================================================

<h2>Sample Output:</h2>

A call to Fib(9) will give the following output:

>> 34

============================================================

<h2>Explanation:</h2>

The above program has been written in R language and it contains comments explaining each of the lines of code. Please go through the comments in the code.

For readability, the actual lines of code have been written in bold face to distinguish them from the comments.

You might be interested in
A car is about to start but it blows up. what is the problem with the car<br> ?
ratelena [41]

Answer:

because there is a bomb

6 0
3 years ago
Read 2 more answers
A satellite orbits the Earth every 2 hours at an average distance from the Earth's centre of 8000km. (i) What is the average ang
AlexFokin [52]

Answer:

i)ω=3600 rad/s

ii)V=7059.44 m/s

iii)F=1245.8 N

Explanation:

i)

We know that angular speed given as

\omega =\dfrac{d\theta}{dt}

We know that for one revolution

θ=2π

Given that time t= 2 hr

So

ω=θ/t

ω=2π/2 = π rad/hr

ω=3600 rad/s

ii)

Average speed V

V=\sqrt{\dfrac{GM}{R}}

Where M is the mass of earth.

R is the distance

G is the constant.

Now by putting the values

V=\sqrt{\dfrac{GM}{R}}

V=\sqrt{\dfrac{6.667\times 10^{-11}\times 5.98\times 10^{24}}{8000\times 10^3}}

V=7059.44 m/s

iii)

We know that centripetal fore given as

F=\dfrac{mV^2}{R}

Here given that m= 200 kg

R= 8000 km

so now by putting the values

F=\dfrac{mV^2}{R}

F=\dfrac{200\times 7059.44^2}{8000\times 10^3}

F=1245.8 N

3 0
3 years ago
Question 2: (a) In your own words, clearly distinguish and differentiate between Ethics in Engineering and Ethics in Computing (
zlopas [31]

Engineering ethics is not without abstraction, but in contrast with computing, it is animated by a robust and active movement concerned with the seamless identification of ethics with practice.

<h3 /><h3>What is engineering?</h3>

This is a branch of science and technology concerned with the design, building, and use of engines, machines, and structures that uses scientific principles.

Comparing ethics in engineering and ethics in computing:

  • Engineering ethics are a set of rules and guidelines. While computing ethics deals with procedures, values and practices.
  • In engineering ethics, engineers must adhere to these rules as a moral obligation to their profession While in computing ethics, the ethics govern the process of consuming computer technology.
  • Following these ethics for the two professions will NOT cause damage, but disobeying them causes damage.

Some practical examples in the computing field:

  • Avoid using the computer to harm other people such as creating a bomb or destroying other people's work.
  • Users also should not use a computer for stealing activities like breaking into a bank or company.
  • Make sure a copy of the software had been paid for by the users before it is used.

Some practical examples in the engineering field:

  • Integrity for oneself.
  • Respect for one another.
  • Pursuit of excellence and accountability.

Hence, Engineering ethics is the field of system of moral principles that apply to the practice of engineering and following them is important to the profession.

Read more about <em>engineering</em> here:

brainly.com/question/17169621

#SPJ1

7 0
2 years ago
Un material determinado tiene un espesor de 30 cm y una conductividad térmica (K) de 0,04 w/m°C. En un instante dado la distribu
aksik [14]

Answer:

Para x=0:

\phi=1.2 W/m^{2}  

Para x=30 cm:

\phi=-2.4 W/m^{2}  

Explanation

Podemos utilizar la ley de Fourier par determinar el flujo de calor:

\phi=-k\frac{dT}{dx}(1)

Por lo tanto debemos encontrar la derivada de T(x) con respecto a x primero.

Usando la ley de potencia para la derivda, tenemos:

\frac{dT(x)}{dx}=300x-30

Remplezando esta derivada en (1):

\phi=-0.04(300x-30)

Para x=0:

\phi=0.04(30)

\phi=1.2 W/m^{2}  

Para x=30 cm:

\phi=-0.04(300*0.3-30)

\phi=-2.4 W/m^{2}    

Espero que te haya ayudado!

4 0
3 years ago
JAVA HADOOP MAPREDUCE
taurus [48]

Answer:

Explanation:

package PackageDemo;

import java.io.IOException;

import org.apache.hadoop.conf.Configuration;

import org.apache.hadoop.fs.Path;

import org.apache.hadoop.io.IntWritable;

import org.apache.hadoop.io.LongWritable;

import org.apache.hadoop.io.Text;

import org.apache.hadoop.mapreduce.Job;

import org.apache.hadoop.mapreduce.Mapper;

import org.apache.hadoop.mapreduce.Reducer;

import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;

import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

import org.apache.hadoop.util.GenericOptionsParser;

public class WordCount {

public static void main(String [] args) throws Exception

{

Configuration c=new Configuration();

String[] files=new GenericOptionsParser(c,args).getRemainingArgs();

Path input=new Path(files[0]);

Path output=new Path(files[1]);

Job j=new Job(c,"wordcount");

j.setJarByClass(WordCount.class);

j.setMapperClass(MapForWordCount.class);

j.setReducerClass(ReduceForWordCount.class);

j.setOutputKeyClass(Text.class);

j.setOutputValueClass(IntWritable.class);

FileInputFormat.addInputPath(j, input);

FileOutputFormat.setOutputPath(j, output);

System.exit(j.waitForCompletion(true)?0:1);

}

public static class MapForWordCount extends Mapper<LongWritable, Text, Text, IntWritable>{

public void map(LongWritable key, Text value, Context con) throws IOException, InterruptedException

{

String line = value.toString();

String[] words=line.split(",");

for(String word: words )

{

Text outputKey = new Text(word.toUpperCase().trim());

IntWritable outputValue = new IntWritable(1);

con.write(outputKey, outputValue);

}

}

}

public static class ReduceForWordCount extends Reducer<Text, IntWritable, Text, IntWritable>

{

public void reduce(Text word, Iterable<IntWritable> values, Context con) throws IOException, InterruptedException

{

int sum = 0;

for(IntWritable value : values)

{

sum += value.get();

}

con.write(word, new IntWritable(sum));

}

}

}

3 0
3 years ago
Other questions:
  • There is a proposal in Brooklyn to construct a new mid-rise apartment building on a vacant lot at the intersection of Avenue A a
    8·1 answer
  • A rotating cup viscometer has an inner cylinder diameter of 2.00 in., and the gap between cups is 0.2 in. The inner cylinder len
    9·1 answer
  • What is temperature coefficient of resistance
    12·1 answer
  • Passband to baseband conversion: Consider the following passband signal,
    14·1 answer
  • A stone-filled pit used for waste disposal is commonly referred to as a
    15·1 answer
  • The outer surface of a spacecraft in space has an emissivity of 0.6 and an absorptivity of 0.2 for solar radiation. If solar rad
    12·1 answer
  • A can of engine oil with a length of 150 mm and a diameter of 100 mm is placed vertically in the trunk of a car. On a hot summer
    8·1 answer
  • A 200-gr (7000 gr = 1 lb) bullet goes from rest to 3300 ft/s in 0.0011 s. Determine the magnitude of the impulse imparted to the
    10·1 answer
  • What is a network? I'LL MARK BRAINLEST
    12·2 answers
  • Algorithm for sum 2+4+6+….+n
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!