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
Adding _____ will allow the user to create text as it will often appear in publications with multiple articles, such as a newspa
mart [117]
Does applications make sense <span />
5 0
3 years ago
Read 2 more answers
What are events in computer programming?
N76 [4]

Answer:

mnkn

Explanation:

3 0
3 years ago
Read 2 more answers
Why is information literacy so important?
olga_2 [115]
It promotes problem solving approaches and thinking skills
6 0
3 years ago
Microsoft word 365 allows cells to be split into how many columns
Bogdan [553]

Answer:

Microsoft word 365 allows two columns

8 0
3 years ago
Read 2 more answers
What is mean by cgi?
kifflom [539]

Answer:

CGI stands for common gateway interface. It is used in transferred information between world wide to the CGI program. As CGI program is the programming language which can be written in java , C and perl. It is a web server dynamically used with users. CGI is a standard used to create web pages by web servers.

4 0
3 years ago
Other questions:
  • What is going to be the shortest, most concise restatement of information?
    10·2 answers
  • Round-robin schedulers normally maintain a list of all runnable processes, with each process occurring exactly once in the list.
    14·1 answer
  • Write c++ program bmi.cpp that asks the user bmi.cpp the weight (in kilograms) and height (in meters).
    12·1 answer
  • Anyone watch anime, i love stay kids and they sang the op for Tower of God XD
    8·2 answers
  • Select the correct line of missing code to create an output of "hello."
    10·1 answer
  • Using a third-party package of your choice, write a program that reads the contents of a csv file and saves it to an Excel file.
    10·1 answer
  • Direction: Write True on the line if the statement is correct. Write False if the statement is incorrect. 1. All objects are com
    13·2 answers
  • Which type of information should never be given out on social media?
    5·2 answers
  • Name and define (or list the set that defines) three of the four common data types in programming
    12·1 answer
  • Question 4 of 25
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!