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
Computer system with a 32-bit logical address and 4k-byte page size. assume that each entry of a page table consists of 4bytes.
Annette [7]

The number of bits in the physical address is 26 bits. The number of entries in a page table is \mathbf{2^{20}} entries. The size of the page table in a one-level paging scheme is 4MB.

<h3>
What is paging in Operating System?</h3>

Paging is a storage method used in operating systems to recover activities as pages from secondary storage and place them in primary memory. The basic purpose of pagination is to separate each procedure into pages.

We are given the following parameters:

  • 32-bit logical address
  • Page size = 4 KB = \mathbf{2^{12} \ bytes }
  • Size of each Page table entry = 4 bytes

Suppose the system supports physical memory size = 64 MB = \mathbf{2^{26} \ bytes}

Thus, the number of bits in the physical address is computed as:

= \mathbf{log_2 \{Physical-memory-size\}}

=\mathbf{log_2(2^{26})}}

= 26 bits

The number of entries in a page table = logical address space size/page size

The number of entries in a page table \mathbf{= \dfrac{2^{32}}{2^{12}}}

\mathbf{=2^{20}} entries

In a one-level paging scheme, the size of the table is:

= entire no. of page entries × page table size

= \mathbf{2^{20}\times 4 \ bytes}

= 4 MB

b.

suppose that this system supports up to 2^30 bytes of physical memory.

  • The size of the page table will be the same as 4 MB due to the fact that the number of entries, as well as, the page table entry size is the same.

Since the size of the page table surpasses that of a single page. A page cannot include a whole page table. Therefore, the page table must be broken into parts to fit onto numerous pages, and an additional level of the page table is required to access this page table.

  • This is called the Multi-Level Paging system.

Therefore, we can conclude that the number of bits in the physical address is 26 bits, the number of entries in a page table is \mathbf{2^{20}} entries, and the size of the page table in a one-level paging scheme is 4MB.

Learn more about Paging in Operating System here:

brainly.com/question/17004314

#SPJ1

4 0
1 year ago
Which two standards below represent newer versions of stp??
valina [46]
Standard Tree Protocol (STP) is a networking protocol that was made by Radia Perlman. It makes a single path over a network, averting any loops from happening. Even if there are multiple paths to the same destinations. It has two never versions which is 802.1s and 802.1w.
8 0
3 years ago
Which of the following are ways that
Viefleur [7K]

Answer:

A and b

Explanation:

3 0
2 years ago
………………….. is the process of causing a system variable to conform to some desired value. Options Control feedback Design none of
frutty [35]
Control <span>is the process of causing a system variable to conform to some desired value. Options Control feedback Design none of the above</span>
4 0
2 years ago
Outside of a C program, a file is identified by its ________while inside a C program, a file is identified by a(n) ________. fil
Alexxandr [17]

Answer: name, file stream object

Explanation:

4 0
2 years ago
Other questions:
  • Write a program to read as many test scores as the user wants from the keyboard (assuming at most 50 scores). Print the scores i
    13·1 answer
  • A(n ____ with a drop down menu provides consistency in function and appearance making it easy for users to learn and work with t
    7·1 answer
  • What is an example of constructive criticism for an employee who is shy during meetings?
    15·2 answers
  • I want to customize my company's logo, name, address, and similar details in all my business documents what option should use?
    12·1 answer
  • How long does it take to wire a house?
    14·2 answers
  • What are the main differences between a workgroup and a domain?
    14·2 answers
  • Please help me!! 10 Points are waiting!!
    8·1 answer
  • A signal has a spectrum from 0 to 145 Hz, as shown below. It is sampled at a rate of 295 Hz. Find the region of the baseband spe
    5·2 answers
  • SeleCT all correct text​
    5·1 answer
  • Question 8 of 10
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!