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]2 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
Error: At least one of the class levels is not a valid R variable name; This will cause errors when class probabilities are gene
qwelly [4]

Using the knowledge in computational language in JAVA it is possible to write a code that use factor levels that can be used as valid R variable names

<h3>Writting the code in JAVA:</h3>

<em>    method  = "repeatedcv"</em>

<em>  , number  = 10</em>

<em>  , repeats = 1 </em>

<em>  , verboseIter = TRUE</em>

<em>  , summaryFunction  = fivestats</em>

<em>  , classProbs = TRUE</em>

<em>  , allowParallel = TRUE)</em>

<em />

<em />

See more about JAVA at brainly.com/question/12975450

#SPJ1

3 0
1 year ago
When you declare a variable of a basic, primitive type, such as int x = 10;, the memory address where x is located holds the ___
Nadya [2.5K]

Answer:

Answer is (d) value of 10

Explanation:

Usually when we write "int x=10;", a memory space is allocated for an integer variable with name x, and content 10.

8 0
2 years ago
Read 2 more answers
When a slide is inserted, it appears A. at the end of the presentation. B. before the selected slide. C. after the selected slid
padilas [110]
C. after the selected slide
8 0
3 years ago
Read 2 more answers
Where could page numbers appear in a properly formatted business document?
Stels [109]
At the bottom right is the perfect place
6 0
3 years ago
Read 2 more answers
research the internet and develop a list of three important rules/standards you will give to the team to help everyone easily fi
natima [27]
The three important rules/standards that I can give to the team to help everyone easily find the documents in the future are the following:
1. Develop naming convention on how to define filename/documents.
2. All changes in the documents must be well documented, there should be a record of changes.
3.There must be a defined standard procedures on how to save and access the file, and who are allowed to modify the documents.
6 0
3 years ago
Other questions:
  • Why do you feel an organization has multiple layers of security in place to protect its operation?
    5·1 answer
  • Alicia uses a software application to store the names, email addresses, and phone numbers of her friends in alphabetical order.
    15·2 answers
  • The manager of a sports club has data about the club members' ages in a workbook. He wants to find which age is most common. Whi
    13·2 answers
  • Which precaution should be taken when working inside computer systems??
    9·1 answer
  • Miriam Is a network administrator. A few employees want to access sensitive Information stored on a backup device. She wants to
    13·1 answer
  • Ron is creating building blocks in Word. How can he make the building blocks that he created available?
    10·2 answers
  • The full meaning of UNIVAC and ENIAC​
    5·2 answers
  • . Why is it important to use Social Media responsibly? ANSWER NOW!!!
    15·2 answers
  • While a remote assistance session is in progress, what keyboard key(s) can the requestor press to terminate the connection?
    10·1 answer
  • You want to select the minimum windows server 2012 edition to support the required roles and hardware. which edition should you
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!