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
weqwewe [10]
3 years ago
11

A triangular number is a number that is the sum of the integers from 1 to some integer n. Thus 1 is a triangular number because

it's the sum of the integers from 1 to 1; 6 is a triangular number because it's 1+2+3=6. Given the non-negative integers m and n (with m < n), create a list of the triangular numbers between (and including) m and n. Thus if m is 3 and n is 20, the list would be: [3, 6, 10, 15]. Associate the list with the variable triangulars.
Computers and Technology
1 answer:
neonofarm [45]3 years ago
4 0

Answer:

  1. m = 3
  2. n = 20
  3. triList = []
  4. current = 0
  5. for i in range(1, n + 1):
  6.    current = current + i  
  7.    if(current >= m and current <= n):
  8.        triList.append(current)
  9. print(triList)

Explanation:

The solution code is written in Python 3.

Firstly, create variable m and n and set the value 3 and 20 to the variables (Line 1 -2)

Create a triangle number list (Line 4)  and another variable current to hold the value of current total of triangle number (Line 5).

Create a for loop and iterate through the number between m and n (Line 6).  Calculate the current total of triangle number (Line 7) and proceed to check if the current triangle number is bigger or equal to m and smaller and equal to n, add the current triangle number to triList (Line 8-9).

Print the triList (Line 11) and we shall get [3, 6, 10, 15]

You might be interested in
Describe how you could obtain a statistical profile of the amount of time spent by a program executing different sections of its
Mazyrski [523]

Answer:

Explanation:

It can be said that the best way to obtain such a statistical profile would be to issue a periodic timer interrupt, then you would simply need to monitor which what code was running when the interruption took place. This information is especially helpful to the programmers as it would allow them to optimize the specific sections of the code that are consuming the most CPU resources, and thus making the overall program more efficient.

7 0
3 years ago
Why is Apple using social media ?
jeka57 [31]

Apple uses social media to promote their products and increase user-engagement. This is a very effective method of advertising.

6 0
4 years ago
Which statement best describes top-down programming design?
MariettaO [177]

B is the answer (i think)

5 0
3 years ago
Describe one reason you would import data into a database.
AURORKA [14]
<span>You typically import data for the following reasons: You want to merge two databases by copying all the objects in one database to another. [ When you import, you can copy all the tables, queries, forms, reports, macros, and modules, along with table relationships, to another database in a single operation. You need to create some tables that are similar to tables that exist in another</span>
6 0
4 years ago
Read 2 more answers
What is a common use for append queries?
Karo-lina-s [1.5K]

Answer:

You use an append query when you need to add new records to an existing table by using data from other sources. If you need to change data in an existing set of records, such as updating the value of a field, you can use an update query.

6 0
3 years ago
Read 2 more answers
Other questions:
  • What are the set of rules to move data from one computer to another?
    11·1 answer
  • In what order does the air flow in a canister vacuum cleaner pass through the following components?
    11·1 answer
  • Which of the following is NOT contained on the Slide Show toolbar?
    11·2 answers
  • Your company has been using Windows workgroups on a server running Windows Server 2016. Due to the rapid growth of the company,
    9·1 answer
  • Convert the expression ((a+b) + c * (d+e) + f) * (g+h) to a:
    13·1 answer
  • There are many advantages and some disadvantages to using social media. Explain at least one of the advantages to
    5·1 answer
  • Which of the following activities would be best-suited for a thinking mind map?
    10·2 answers
  • Which is better Play Station Xbox or PC
    14·2 answers
  • What best describes the computer's BIOS (basic input-output system)?
    5·1 answer
  • Which of the following is a true statement about parameters in data management? Check all that apply.
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!