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
Novosadov [1.4K]
3 years ago
13

We will pass in a value N. Write a program that outputs the complete Fibonacci sequence for N iterations. Important: If N is 0,

then we expect to get an output of 0. If N=1 then we expect 0, 1 etc.
Computers and Technology
1 answer:
jasenka [17]3 years ago
3 0

Answer:

The program written in Python is as follows

def fibonac(N):

    series = ""

    for i in range(0,N+1):

         series = series + str(i) + ","

   return series[:-1]

N = int(input("Number: "))

print(fibonac(N))

Explanation:

This line defines the function fibonac

def fibonac(N):

This line initializes variable "series" to an empty string

    series = ""

This line iterates through the passed argument, N

    for i in range(0,N+1):

This line determines the Fibonacci sequence

         series = series + str(i) + ","

Lastly, this line returns the Fibonacci sequence

   return series[:-1]

The main starts here

The firs line prompts user for input

N = int(input("Number: "))

This line prints the Fibonacci sequence

print(fibonac(N))

You might be interested in
Basically, if for every row, the absolute value of the entry along the main diagonal is larger than the sum of the absolute valu
Elza [17]

Answer:

Check the explanation

Explanation:

MATLAB code:

%----------------------

function result = dominant(A)

% matrix dimensions

d = size(A);

% for loop over rows

for i = 1:d

% sum of row elements except diagonal element

sum_row =0;

% for loop over columns

for j = 1:d

% adding each elements to sum variable

sum_row = sum_row+ abs(A(i,j));

end

%subratcting diagonal element

sum_row = sum_row-abs(A(i,i));

%checking dominant condition

% failed once means matrix is not diagonal dominant

if abs(A(i,i))< sum_row

result = 'false';

return;

end

end

% dominant condition not failed

result = 'true';

end

% matrix A

A = [ 3 -2 1; 1 -3 2; 1 2 6]

% result

result = dominant(A)

% matrix A

A = [ -2 1 2; 1 3 2; 1 -2 0]

% result

result = dominant(A)

%----------------------

Kindly check the attached output image below.

3 0
3 years ago
A half-life is the amount of time it takes for a substance or entity to fall to half its original value. Caffeine has a half-lif
Elena L [17]

Answer:

// here is code in java.

import java.util.*;

class Solution

{

// main method of class

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

{

   try{

    // declare variable

         double caffeine;

    // scanner object to read input from user

       Scanner scr=new Scanner(System.in);

       System.out.print("Enter the initial amount of caffeine:");

        // read the initial amount of caffeine

           caffeine=scr.nextDouble();

          // calculate amount of caffeine after 6,12,18 hours

          for(int i=1;i<=3;i++)

          {

               System.out.println("After "+ i*6+" hours:"+(caffeine/2)+" mg");

               // update the caffeine after every 6 hours

               caffeine=caffeine/2;

          }

                 

   }catch(Exception ex){

       return;}

}

}

Explanation:

Create a variable "caffeine" to store the initial amount of caffeine given by user. Run a loop for three time, it will calculate the amount of caffeine left after every 6 hours.First it will give the amount of caffeine left after 6 hours, then caffeine left after 12 hours and in last caffeine after 18 hours.

Output:

Enter the initial amount of caffeine:100

After6 hours:50.0 mg

After12 hours:25.0 mg

After18 hours:12.5 mg

8 0
4 years ago
What is the difference between internet and intranet​
Elenna [48]

Answer:

The Internet is a globally-connected network of computers that enables people to share information and communicate with each other. An intranet, is a local or restricted network that enables people to store, organize, and share information within an organization.

Explanation:

4 0
3 years ago
Read 2 more answers
Select the correct answer.
Nutka1998 [239]

Answer:

database design is the correct e

6 0
3 years ago
Suppose that the UDP receiver computes the Internet checksum for the received UDP segment and finds that it matches the value ca
defon

Answer:

No, the receiver cannot be absolutely certain that no bit errors have occurred. This is because of the manner in which the checksum for the packet is calculated. If the corresponding bits (that would be added together) of two 16-bit words in the packet were 0 and 1 then even if these get flipped to 1 and 0 respectively, the sum still remains the same. Hence, the 1s complement the receiver calculates will also be the same. This means the checksum will verify even if there was transmission error

Explanation:

4 0
3 years ago
Other questions:
  • Which statement about word processing software is true? A)You can use it to perform mathematical calculations.B) You can use it
    6·2 answers
  • In this mode, your presentation will fill up the entire screen. Auto Default Standard Window
    6·2 answers
  • What function does a security certificate perform
    15·2 answers
  • What is one of the first steps a financial planner might take when working with a client?
    14·2 answers
  • What is the importance of charts and graphics in providing<br> information?
    15·1 answer
  • LAB: Convert to binary - methods
    11·1 answer
  • Which is a method used with arrays?<br><br> find<br><br> index<br><br> insert<br><br> sort
    8·1 answer
  • TOT al<br>Name TWO examples of these settings and utilities. (2)​
    12·1 answer
  • What is mean by SEO?
    7·2 answers
  • Which option is designed by software engineers?
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!