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
Firlakuza [10]
3 years ago
13

Write a recursive method called, doMyMath, which takes as input any positive integer and calculates the factorial (use comments

for necessary items).
Computers and Technology
1 answer:
gulaghasi [49]3 years ago
6 0

Answer:

def doMyMath(n):  

    if n == 1:  

         return n  

    else:  

         return n*doMyMath(n-1)  

Explanation:

This line defines the function

def doMyMath(n):  

This line checks if n is 1. If yes, it returns n (1)

    if n == 1:  

         return n  

If otherwise, it calculates the fibonacci recursively

    else:  

         return n*doMyMath(n-1)  

To call the function from main, you can use:

print(doMyMath(5))

or

num = int(input("Number: "))   --- This gets the number from user

print("Result: ",doMyMath(num)) --- This calculates the factorial

<em>This question is answered in Python</em>

You might be interested in
-Give a definition of the critical section problem and explain the purpose of the entry and exit code blocks
Alisiya [41]

Answer: In operating system a code segment which accesses  some shared variables or resources one at a time atomically such other no other code or process is accessing that resource or variable at the same time.

Entry section code block allows the access to the shared resource or variable and exit section code signals the termination from access to the shared resource or variable.

Explanation:

Entry and exit section codes needs to check certain properties before allowing the access and removal of access to a particular code segment.

These conditions are:

1. Bounded waiting.

2. Mutual exclusion.

3. checking thread execution status to allows other threads to enter the critical section (CS).

6 0
3 years ago
You are a network engineer tasked with performing a site survey for a multiple-channel architecture (MCA) system in a three-stor
blagie [28]

Answer:

20/20 vision, and quick internal math if you are talking about human characteristics. If you are talking about the sight survey itself and considering other aspects; You would want to make sure the site has an easily accessible area for the client, doing this by considering the following: easy access, building height (cell phone tower correspondents), multi-channel sight points, and wiring less visible than the access point.

Explanation:

5 0
3 years ago
What is java programing <br>​
sesenic [268]

Answer:

Explanation:

Java is a class-based, object-oriented programming language that is designed to have as few implementation dependencies as possible. ... Java applications are typically compiled to bytecode that can run on any Java virtual machine (JVM) regardless of the underlying computer architecture

8 0
3 years ago
Read 2 more answers
Technological advances have led to worldwide increased ______.
kumpel [21]

Answer:

C

Explanation:

4 0
3 years ago
Read 2 more answers
The primary benefit to client/server applications is that multiple people can be working with the same data at the same time
yawa3891 [41]

Answer:

uhhh false i think

Explanation:

3 0
3 years ago
Read 2 more answers
Other questions:
  • A(n) ________ signal is a discrete, binary waveform that transmits data coded into two discrete states such as 1-bits and 0-bits
    12·1 answer
  • How do i know if i got flash installed onchrome
    5·1 answer
  • A business wants to centralize its administrative tasks. At the same time, it wants the existing systems to manage and sustain t
    14·2 answers
  • The first step in the five-step process for problem solving is to ____. take action complete the task understand the task or nee
    10·2 answers
  • What are the best data structures to create the following items? And why?
    13·1 answer
  • Why does atmospheric pressure does not effect on planes,jet planes and rocket?​
    9·1 answer
  • Write a print statement that displays a random integer between 5 and 5000. Assume the random library is imported.
    12·1 answer
  • The average American has 10 devices, ask for users average number of devices. Any number between 7 and 12 will print “you have a
    13·1 answer
  • Which is an effect of short-term environmental changes?
    8·1 answer
  • Fill _________ skips the Saturday and Sunday dates in a date fill.
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!