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
What is an IP address and where I can find the IP address for my computer?
pantera1 [17]

Answer:

a) and b) are correct.

Explanation:

You can also type ipconfig on windows terminal to see your ip address - or ifconfig if you are running linux / macos terminal.

3 0
3 years ago
Anyone on ps4 willing to trade me a fennec or McClaren on rocket league?
Gnom [1K]
Bet bet bet i gotcha— my user is “stinkyminky84” sorry about the name i know ya weird lol.
3 0
3 years ago
Read 2 more answers
Management information system by different outhors<br>​
morpeh [17]

Answer:

Explanation:

.....

...,....

8 0
2 years ago
Which of the following occurs during data cleansing?
Diano4ka-milaya [45]

Answer:c)Clean redundant customer data

Explanation:Data cleansing/cleaning is the activity for the elimination of the data which is not required for further use, corrupt, unnecessary etc by detecting it. The data that is being cleared is categorized by levels like irrelevant  data, incorrect data, inaccurate data, redundant data etc.

The data is eliminated by the method of correcting , modifying, reducing unnecessary parts,deleting, etc.Thus, the correct option is option(C).

5 0
3 years ago
The DNS server at your headquarters holds a standard primary zone for the abc domain. A branch office connected by a slow WAN li
mafiozo [28]

Answer:

In the SOA tab of the zone's Properties dialog box, increase the refresh interval.

Explanation:

5 0
3 years ago
Other questions:
  • What effects will the different types of lighting produce on mountains?
    15·1 answer
  • Virtual private network requires a secure remote connections<br><br> true or false?
    11·1 answer
  • A _____ is the useful part of a transmission through a network.
    15·1 answer
  • What is runtime error in Python? Provide an example
    14·1 answer
  • Write a program that displays the following menu:
    8·1 answer
  • Write a string class. To avoid conflicts with other similarly named classes, we will call our version MyString. This object is d
    5·1 answer
  • A good CRM should Integrate marketing, sales, and customer support activities measuring and evaluating the process of knowledge
    13·1 answer
  • Write a function called prod_all that takes any number of arguments and returns their sum. Test the function by using these two
    10·1 answer
  • If Anyone can help me out that'll be great
    11·1 answer
  • It is where your cpu (processor) is installed
    10·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!