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
bogdanovich [222]
3 years ago
5

Implement a recursive program that takes in a number and finds the square of that number through addition. For example if the nu

mber 3 is entered, you would add 3+3+3=9. If 4 is entered you would add 4+4+4+4=16. This program must be implemented using recursion to add the numbers together. mips

Computers and Technology
1 answer:
lubasha [3.4K]3 years ago
3 0

Answer:

def recurSquare(n):

   if n == 0:

       return 0

   return recurSquare(n-1) + n + n-1

print(recurSquare(2))

Explanation:

Programming language used is Python.

The recursive function is defined as  recurSquare(n)

The IF statement checks the argument that is passed to the function to ensure it is not equal to zero.

The function is a recursive function, which means it calls itself.

In the return statement the function calls itself and the argument is reduced by 1.

The function keeps calling itself until n is equal to zero (n == 0) it returns zero and the function stops.

You might be interested in
......... mi2hej<br><br>ejid8eo19o1b2bxhxjxjdnneejk2929nr
Mila [183]

Answer:

hi  thsu si s5

Explanation:

brace use

5 0
2 years ago
Read 2 more answers
Manipulate the SQL statement to pull ALL fields and rows from Customers table that have a PostalCode of 44000. TIP: Since Postal
padilas [110]

Answer:

There are two customers in the PostalCode.

SQL statement for select all the fields and the rows from the Customers table where PostalCode is 44000.

SELECT *  FROM Customers  WHERE PostalCode = "44000";

Explanation:

The SELECT statement retrieve zero or more than one row from 1 or more than one the database tables or the database views.  

In most of the applications, the SELECT query is most commonly used for DQL(Data Query Language) command.  

SQL is the declarative programming language and the SELECT statement specifies the result set, but they do not specifies how to calculate it.

6 0
3 years ago
Write a program using Python that prompts for an integer and prints the integer, but if something other than an integer is input
Tcecarenko [31]

Answer:

#program in Python

#read until user Enter an integer

while True:

   #try block to check integer

   try:

       #read input from user

       inp = int(input("Enter an integer: "))

       #print input

       print("The integer is: ",inp)

       break

   #if input is not integer

   except ValueError:

       #print message

       print("Wrong: try again.")

Explanation:

In try block, read input from user.If the input is not integer the print a message  in except block.Read the input until user enter an integer. When user enter an  integer then print the integer and break the loop.

Output:

Enter an integer: acs                                                                                                      

Wrong: try again.                                                                                                          

Enter an integer: 4a                                                                                                      

Wrong: try again.                                                                                                          

Enter an integer: 2.2                                                                                                      

Wrong: try again.                                                                                                          

Enter an integer: 12                                                                                                      

The integer is:  12  

7 0
3 years ago
Read 2 more answers
Suppose I have two DFAs D1, D2 and I perform the product construction on them to get a DFA for the union of their languages. Wha
Musya8 [376]

Answer:

Explanation:

If L(D1) = L(D2), the D has every state being final

If L(D1) = L¯(D2), the D has every state being final

If L(D1) = ∅, then L(D) = L(D2).

If L(D1)=Σ, L(D) = L(D2)

8 0
3 years ago
Once you fix the bug in a code, what is the last thing you should do?
aleksklad [387]

Answer:

Know what the code should do

4 0
3 years ago
Other questions:
  • Select the most likely outcome of making only on-time minimum payments to a credit card with a balance for an entire year?
    7·2 answers
  • Technology offers a variety of rich opportunities available to teachers and students. According to Inan and Lowther (2010), ther
    6·1 answer
  • 2. What type of expansion card allows your computer to
    12·1 answer
  • According to the ethical computer use policy, users should be __________ of the rules and, by agreeing to use the system on that
    11·1 answer
  • print out the last even number from an array of integers, if there is no even number, then print out a sentence indicating so.
    5·1 answer
  • The stack pop operation
    10·1 answer
  • 3.26 LAB: Leap Year A year in the modern Gregorian Calendar consists of 365 days. In reality, the earth takes longer to rotate a
    15·2 answers
  • What is an operating system? What are the main functions of a modern general purpose operating system?
    7·1 answer
  • Suppose you want to boot a VM from its virtual DVD drive, but it boots to the VM’s hard drive. Which of the following could be t
    12·1 answer
  • What is the purpose of a format painter in Word?
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!