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
marta [7]
3 years ago
7

Complete the following Programming Assignment using Recursion. Use good programming style and all the concepts previously covere

d. Submit the .java files electronically through Canvas by the above due date (In a zip file). This also includes: Requirements (for this problem), Pseudo-Code, UML, Java Doc(s) and an explanation, etc., which must be in the correct format. 9. Ackermann's Function Ackermann's function is a recursive mathematical algorithm that can be used to test how well a computer performs recursion. Write a method ackermann(m, n), which solves Ackermann's function. Use the following logic in your method: If m=0 then return n +1 If n = 0 then return ackermann (m - 1, 1) Otherwise, return ackermann (m - 1, ackermann(m, n - 1)) Test your method in a program that displays the return values of the following method calls: ackermann(0, 0) ackermann (0, 1) ackermann(1, 1) ackermann(1, 2) ackermann(1, 3) ackermann(2, 2) ackermann(3, 2)
Computers and Technology
1 answer:
Likurg_2 [28]3 years ago
6 0

Answer:

Explanation:

public class Ackermann {

   public static int ackermann's(int m, int n) {

       if (m == 0) {

           return n + 1;

       } else if (n == 0) {

           return ackermann's(m-1, 1);

       } else {

           return ackermann(m - 1, ackermann(m, n - 1));

       }

   }

   public static void main(String[] args) {

       System.out.println(ackermann(0, 0));

       System.out.println(ackermann(0, 1));

       System.out.println(ackermann(1, 1));

       System.out.println(ackermann(1, 2));

       System.out.println(ackermann(1, 3));

       System.out.println(ackermann(2, 2));

       System.out.println(ackermann(3, 2));

   }

}

1

2

3

4

5

6

7

29

Process finished with exit code 0

You might be interested in
Design and implement a program that reads a series of 10 integers from the user and prints their average. Read each input value
irina [24]

Answer:

Explanation:

The following program was written in Java. It creates a loop that asks the user for numbers. If it can convert it to an integer it accepts it and adds it to the sum variable otherwise it ouputs that it is not a valid number. Once all 10 integers are added it prints the Average of the values entered.

import java.util.ArrayList;

import java.util.Scanner;

class Brainly {

   public static void main(String[] args) {

       Scanner in = new Scanner(System.in);

       int count = 0;

       int sum = 0;

       while (count != 10) {

           System.out.println("Enter a number: ");

           String answer = in.nextLine();

           try {

               int intAnswer = Integer.parseInt(answer);

               sum += intAnswer;

               count += 1;

           } catch (NumberFormatException e) {

               System.out.println("Not a valid number.");

           }

       }

       int average = sum / count;

       System.out.println("Average: " + average);

   }

}

3 0
3 years ago
In ipv6, what field is used to indicate what sequence of packets from one source to one or multiple destinations a packet belong
deff fn [24]

Answer:

Flow label

Explanation:

A Flow label in IPv6 is a value given to a sequential flow of packets. To better understand what a flow label is, we need to know what a flow is first. A flow is a series of packets sent from a combination of a source address to a destination address. The routers configured to deal with IPv6 addresses handle these flows. Therefore, a flow label makes delivery of packets that belong to other similar sequential packets from source to destination or multiple destinations a priority.

5 0
3 years ago
Which tool would you use if you wanted to arrange a list of words in alphabetical order?
dem82 [27]
Answer:
A
Explanation:
You can quickly and easily sort the text of a bulleted or numbered list in Microsoft's popular Word program so that your text is in alphabetical order. In the Sort Text dialog box, under Sort by, click Paragraphs and Text, and then click either Ascending or Descending.
5 0
3 years ago
Read 2 more answers
A security analyst recommends implementing SSL for an existing web service. A technician installs the SSL certificate and succes
forsale [732]
C- I think. I hope this helps you.
4 0
3 years ago
Which phrase best describes a spreadsheet?
choli [55]

Answer:

  (d) a computer file that uses rows and columns to organize, analyze, store, and manipulate data

Explanation:

A spreadsheet program and its associated data structure (a spreadsheet) are intended to emulate the appearance of a ledger that is organized into rows and columns.

4 0
2 years ago
Other questions:
  • Harold wants to create a design that would depict the innocent and evil sides of human nature. Which colors can Harold use to de
    13·1 answer
  • To insert a new slide in an existing presentation, what menu should you select?
    5·2 answers
  • All ofthe following are correct EXCEPT one option when it comes towriting disappointing news letters. Identify theexception.
    6·1 answer
  • OSHA requires training for employees on the hazards to which they will be exposed.
    12·2 answers
  • When would you use an omnidirectional microphone?
    9·1 answer
  • A ___ is a node (or a device) that connects two different networks together and allows them to communicate.
    12·1 answer
  • When replacing a system board in a laptop, which feature is a must?
    10·1 answer
  • What is the name of a button on a website?
    11·1 answer
  • If an if-else statement is true, it will include which kinds of results?
    6·1 answer
  • Please answer fast computer picture above​
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!