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
What does XML do with a data wrapped in the tags?
Arlecino [84]

Answer:

Especificación para diseñar lenguajes de marcado, que permite definir etiquetas personalizadas para descripción y organización de datos. ¿Para que sirve XML? Representar información estructurada en la web (todos documentos), de modo ... Las etiquetas se definen para crear los documentos, no tienen un significado

Explanation:

5 0
3 years ago
Which of the following best explains how symmetric encryption are typically used?
Y_Kistochka [10]

A: Symmetric encryption uses a single key that should be kept secret. The same key is used for both encryption and decryption of data.

6 0
3 years ago
JAVA
marshall27 [118]

Answer:

Answer is in the provided screenshot!

Explanation:

Steps required to solve this problem:

1 - define what characters are "vowels" by assigning them to an array.

2 - create a variable to record the amount of vowels there are in the string.

3 -  convert the input string into a character array and iterate through each character

4 - for each of the character of the string we go through, check if it matches any of the vowels

5 - return true if the vowel count is greater than 1

Alternative methods using the Java Stream API have also been wrote, please respond if you require them.

7 0
3 years ago
What is element 115 and what is it from?<br> Also what did it do?
tekilochka [14]
Its temporary name, which is being used as a placeholder, is ununpentium. Element 115<span> is one of a number of super heavy </span>elements—elements<span> with an atomic number greater than 104—that are so short-lived, they can't be detected in nature. ... Creation of </span>element 115<span> during a particle collision of americium and calcium atoms</span>.
7 0
3 years ago
Which function can be used to insert the current date into a spreadsheet?
VladimirAG [237]

Answer:

im pretty sure it MM/DD/YYYY

Explanation:

3 0
3 years ago
Other questions:
  • Which function can you use to abbreviate the lengthy expression, A1+A2+A3+A3...+A19+A20?  MAX COUNT SUM ROUND
    10·2 answers
  • The computers connected to the main server are called ______.
    14·2 answers
  • You can add envelopes to existing documents. <br> a. True <br> b. False
    10·1 answer
  • Computer programmers often use binary codes (strings of 1s and 0s) to write programs for computers. These codes are then changed
    6·1 answer
  • Read the scenario below. Explain why this is not fair use of copyright materials. What should you do instead of using the entire
    10·1 answer
  • A ___________ is the smallest unit in a written language.
    7·2 answers
  • Controlling the physical world with sensors and digital devices depends on bandwidth and the ability to analyze data in real tim
    5·1 answer
  • You view a portion of a document on the screen through a
    14·1 answer
  • What happens if i unplug my alarm system?
    11·1 answer
  • What is the command to list the contents of directors in Unix- like operating system
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!