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]
3 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]3 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
The steps for moving data from one cell to another are _____.
VMariaS [17]

The answer is C because you wouldn’t place it in the middle

8 0
3 years ago
WILL GIVE BRAINLIEST!!! Danielle is warehouse supervisor for a large shipping company. Most shipments need to leave the warehous
VMariaS [17]

Answer:

Punctuality

Explanation:

She needs to get there earlier so that she can see the drivers out on time.

4 0
2 years ago
An application programming interface (API) is ________. A) the code the application software uses to take advantage of code writ
Lapatulllka [165]

Answer:

A) the code the application software uses to take advantage of code written by others

Explanation:

An API is a tool widely used in the development of moderm software applications, it is basically a set of protocols and routines that specifies how the software application should interact with others. It provides the interface of the communucation link for the different parts of the program. The intent of APIs is for the simplification of software development and maintenance.

7 0
3 years ago
A spreadsheet contains the maximum weight and maximum height for fifty dog breeds. The breeds are located in rows, and the weigh
MrRa [10]

Answer:

a. Locate

Explanation:

Question options (obtained on the net):

a. Locate

b. Sort

c. Filter

d. Replace

Explanation:

The largest value of the weights of the dog breed in row 43 is the maximum weight of the dog breed in the row

The 'MAX' formula or the 'Autosum' tool can be used to give the largest value in a row, or column

To locate the maximum value in MS Excel, the ADDRESS and MATCH and MAX functions are combined and entered into the blank cell on the right, specifying the same range for the MAX and MATCH functions, and a '0' for the MATCH function as well as a '1' for the ADDRESS function as follows;

=ADDRESS(MATCH(MAX(A1:E1), A1:E1, 0), 1)

Therefore, to navigate to the maximum weight, Emily should use a <em>locate</em>(ing) tool navigate to the information on the spread sheet

8 0
3 years ago
9. What is the difference between a hand-drawn sketch, a working drawing, and a 3D model?
jarptica [38.1K]
A hand draw sketch is drawing with just a pencil and paper. Also, a working drawing is a drawing on at a job. The 3D sketch is on the computer.

3 0
3 years ago
Other questions:
  • Data is: a. Information endowed with relevance and purpose b. Set of specific objective facts or observations c. Some informatio
    10·1 answer
  • Which software product release category is "generally feature complete and supposedly bug free, and ready for use by the communi
    7·1 answer
  • How many bytes of information can be stored on a hard drive?
    7·1 answer
  • Problem 5. (Greatest Common Divisor) Write a program gcd.py that accepts p (int) and q (int) as command-line arguments, and writ
    13·1 answer
  • How do you respond to an email?
    6·1 answer
  • How do you close a file?
    12·2 answers
  • There are....... section in<br>cpu<br>​
    15·1 answer
  • Karin realized that a song takes up a lot more space on her computer than the lyrics of the song typed out in ms word document .
    12·1 answer
  • Text Questions
    15·1 answer
  • I want to start a debate about something
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!