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
When replacing a system board in a laptop, which feature is a must?
Sphinxa [80]
I would use a dual core Becuase a quad can be too space consuming and it can overheat the computers software
6 0
3 years ago
Ranges of IP address that anyone can use for their internal networks are known as ______.
Rama09 [41]
Since no answer choices, have to deduce it is Private Networks
8 0
3 years ago
Read 2 more answers
Traditionally, remote administrative access on routers was configured using Telnet on TCP port 23. However, Telnet was developed
FinnZ [79.3K]

<u>Explanation</u>:

It is an all-too-often used technology today in connecting several computers together via a network.

Routing simple terms means the action of selecting the path taken by the traffic of data in a network of computers. The routing systems involve the use of both wireless and cable based architectures. Some common example of routing systems includes:

  1. Dynamic Routing
  2. Static routing
  3. Default Routing
5 0
3 years ago
Write a program that print "Censored" if userInput contains the word "darn", else print userInput. End with newline.
Ainat [17]

Answer:

userInput = input("Please enter a string of words ")

userInput.split ()

for item in userInput.split ():

   if item =="darn":

       print("Censored")

       break

else:

   print(userInput)

Explanation:

Using Python programming language, the input function is used to receive the users input and save in a variable userInput

Then the .split method is used to convert the words into a list of words.

Using a for loop, the code checks for the word darn and prints censored if it exists else it prints the userInput

7 0
2 years ago
Usually, the same software that is used to construct and populate the database, that is, the DBMS, is also used to present ____.
anygoal [31]

Answer: Queries

Explanation: A database management system(DBMS) is a system that contains the data/information in the form of content or tables.There is a software that can populate the system by the excess data usually found in the SQL format

A query is the demand for the extraction of the information that is present in the database table or content.It helps in presenting extracted data in the readable data.The most commonly used language for the queries is the SQL (structured query language) queries.Thus, the correct option is queries.

3 0
2 years ago
Other questions:
  • A page-replacement algorithm should minimize the number of page faults. We can achieve this minimization by distributing heavily
    14·1 answer
  • To download a webpage, the web browser copies files and transfer them to your ____
    14·2 answers
  • (Game Design) Which of the following is NOT a name of a popular digital sculpting application?
    13·1 answer
  • Develop a C++ program that will determine whether a department store customer has exceeded the credit limit on a charge account.
    13·1 answer
  • We have a 16 GB main memory and 256 MB fully-associative cache, with block size of 64 bytes. We wish to store a 6 x 6 matrix in
    5·1 answer
  • Number are stored and transmitted inside a computer in the form of​
    6·1 answer
  • g Which of the following factors primarily determines how the Internet is used in different countries? A. local attitude to info
    6·1 answer
  • Anyone know how to fix this problem on Microsoft Team?
    14·2 answers
  • Anyone who know hacking​
    7·1 answer
  • Examine the following output:
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!