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
bezimeni [28]
4 years ago
13

1. Implement a method factorial(int n), that takes a number (int) and returns its factorial. Factorial of an integer is the prod

uct of all positive integers less than or equal to it. Method needs to be implemented using recursion.
Computers and Technology
1 answer:
marysya [2.9K]4 years ago
6 0

Answer:

import java.io.*;

import java.util.*;

public class Main

{

public static int factorial(int n){

if (n == 0)

return 1;    

else

return(n * factorial(n-1)); //recursively calling factorial function

}

public static void fibbonaci(int n)

{

if(n>0)

{

c=a+b; //next term in series

a=b;

b=c;

System.out.print(" "+c);    

fibbonaci(n-1); //recursively calling fibbonaci function

}

}

static int a=0,b=1,c;

  public static void main(String[] args) {

  int list_num,fact;

      List<Integer> num=Arrays.asList(1,3,5,7,9); //arraylist with 1,3,5,7,9

      for(Integer i:num) //for-each loop

      {    

      a=0;

      b=1;

      list_num=i.intValue();

      System.out.println("Fibbonaci series for "+list_num);

      System.out.print(a+" "+b);

      fibbonaci(list_num-2); //calling fibbonaci for values in list

      fact=factorial(list_num); //calling factorial for values in list

      System.out.println();

      System.out.println("Factorial for "+list_num+" is "+fact);

      System.out.println();

     

      }

  }

}

You might be interested in
13. What is the suggested rpm on a hard drive for a laptop?
mario62 [17]
Usually it’s either 5400 or 7200RPM
3 0
4 years ago
Adam is an Engineering student but has decided that he does not want to work in that field, but in the Manufacturing career clus
Flura [38]

He should try the <em>Manufacturing Production Process Development pathway </em>

8 0
3 years ago
Read 2 more answers
Choose all that apply.
kirill115 [55]

Answer:

Bullets can be turned off and on.

Lists don't have to use numbers or bullets.

Explanation:

because L just wanted the light

6 0
3 years ago
Read 2 more answers
You decide to add 3 new hard drives to your computer so that you can increase the amount of storage one it when you install them
Tasya [4]

Answer:

b. Use a Molex to SATA power adapter.

Explanation:

SATA power connector is a 15 pin power connector that is used to connect many computer parts like hard drive, cd drive, SSD, etc.

Molex connector is an old connector that is used as a power connector instead of a SATA connector on the same devices.

But the SATA connector overcomes the Molex connectors as it is easy to use and easy to install and can widely be used in many peripherals.

But even now power supply of the computer contains the SATA power connector as well as some spare Molex connector, which can be used when required.  

There are many Molex to SATA connectors that are easy to use when there is a shortage of SATA power.

So, according to the scenario, the most appropriate answer is option b.

3 0
3 years ago
which of the following devices and and receive information from other device? a parallel port B serial port C video port d both
skad [1K]

Answer:

umm

Explanation:

i don't think this is the question look at your wording

6 0
3 years ago
Other questions:
  • Data mining must usestatistics to analyze data.<br> True<br> False
    12·1 answer
  • Select the correct answer. Ryan received an email from a person claiming that he is an employee of the bank in which Ryan has a
    11·2 answers
  • What is a computer network that provides connectivity in a geographic area or region larger than that covered by a local area ne
    7·1 answer
  • You are planning to buy a new server that will act as the server portion of a client/server application. A colleague of yours ma
    9·1 answer
  • The Python print function
    9·1 answer
  • ICD-10-CM diagnosis codes are entered in Block 21 of the CMS-1500 claim. A maximum of __________ ICD-10- CM codes may be entered
    14·1 answer
  • What is the correct html element for playing audio files?
    11·1 answer
  • Which tags do you use to write the header and items of an ordered list on a web page?
    14·1 answer
  • ## Inputs
    15·1 answer
  • 1.
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!