answer.
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]
1 year 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]1 year 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
Write a class called Counter that represents a simple tally counter, which might be used to count people as they enter a room. T
Sonja [21]

Answer:

Code is in java

Explanation:

Code is self explanatory, added come comments to explain more about the code.

public class CounterDriver {

   public static void main(String[] args){

       // Creating counter first object

       Counter counter1 = new Counter();

       //performing 2 clicks

       counter1.click();

       counter1.click();

       // displaying counter 1 click count

       System.out.println("Total Number of counter1 clicks :"+counter1.getCount());

       // resetting counter 1 click count

       counter1.reset();

       // again displaying click count which will be 0 after reset

       System.out.println("Total Number of counter1 clicks :"+counter1.getCount());

      // Same operation goes with counter 2  

       // the only difference is that it performs 3 clicks

       Counter counter2 = new Counter();

       counter2.click();

       counter2.click();

       counter2.click();

       System.out.println("Total Number of counter2 clicks :"+counter2.getCount());

       counter2.reset();

       System.out.println("Total Number of counter2 clicks :"+counter2.getCount());

   }

}

class Counter{

   int count;

// defining constructor which will initialize count variable to 0

   public Counter(){

       this.count=0;

   }

// adding click method to increment count whenever it's called

   public void click(){

       this.count++;

   }

// getCount method will return total count

   public int getCount(){

       return this.count;

   }

// reset method will set count to 0

   public void reset(){

       this.count = 0;

   }

}

4 0
1 year ago
Fiona is drawing polygons on a computer. She wants to map a regular 9-sided polygon back onto itself using a reflection. Which s
Rus_ich [418]
The answer is "<span>B) any perpendicular bisector of one of the sides".
</span>
We can define a line of reflection as the line in which a shape is reflected, or we can say that it is the mirror in which the shape is reflected. The line of reflection is the perpendicular bisector of any pair of corresponding points. If you want to join sets of corresponding points on the object and image, then the line of reflection will slice the lines framed down the middle.
4 0
1 year ago
Read 2 more answers
What does Josh Silverman name as the most important aspect of managing finances?
Andre45 [30]

The answer is a the first one

6 0
1 year ago
Read 2 more answers
When a file is transferred between two computers, two acknowledgment strategies are possible. In the first one, the file is chop
ExtremeBDS [4]

Answer:

Client server system, packets in the network and the discussion regarding two approaches have been done. See the attached pictures.

Explanation:

See attached pictures for explanation.

4 0
2 years ago
Ryan is applying a sort to the data in a table that you have inserted in Word. Which option is important for most tables that ha
Mademuasel [1]

Answer:

D). Choose the correct sort field

Explanation:

You can arrange in descending, or you can arrange in ascending. And C, has nothing to do with this requirement. You don't have this option available with you. Select the option, "My list has header row" is not available to us. And clearly, you need to choose the best sort field first. And then you can arrange or sort accordingly.

7 0
2 years ago
Read 2 more answers
Other questions:
  • What is the output of 1101 x 10 == 11000 + 10?
    12·1 answer
  • Catherine wants to search online for fruit juices. She is fine with aerated or fresh fruit juices. Which Boolean operator will e
    12·2 answers
  • Witch printer covers a large range of colors than any other printer does
    15·2 answers
  • An administrator has initiated the process of deploying changes from a sandbox to the production environment using the Force IDE
    5·1 answer
  • Write a do-while loop that asks the user to enter two numbers. The numbers should be added and the sum displayed. The user shoul
    13·1 answer
  • c++ You are given an array A representing heights of students. All the students are asked to stand in rows. The students arrive
    5·1 answer
  • Question 1 :Which type of unshielded twisted pair (UTP) cable is commonly used for 1000BASE-T Ethernet networks and is often mad
    8·1 answer
  • Joe wants to use an engaging image as a hook in his presentation , but he’s afraid of violating any copyright law. What should h
    10·1 answer
  • You are responsible for a rail convoy of goods consisting of several boxcars. You start the train and after a few minutes you re
    8·1 answer
  • Doug grew up on a large farm in southwest Wisconsin. As a college graduation gift, Doug’s father gave him several hundred acres
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!