I’m working on a problem for a programming class that states the following:

Write a for loop in the space below which will add the numbers between 1 and 20.

To me this means the question is looking for the total sum of all the individual numbers from 1 up to 20 (1 + 2 + 3 + 4 + 5 + … + 20).

Is my understanding correct?
Are there any other ways to word this?

  • Hey all, I'm just starting to get acquainted with english.stackexchange. Could you please suggest any additional tags I could have used for this question? Also, if you could please let me know if I'm incorrectly using any of the tags I have up currently. Oct 26, 2011 at 21:11
  • 5
    Related: “Between A and B” or “from A to B”
    – aedia λ
    Oct 26, 2011 at 21:17
  • 4
    What a teacher! Good way to confuse students!
    – Terry Li
    Oct 26, 2011 at 21:29
  • 1
    Since it's a programming class, the instructor could have assumed a minimum level of math competency, and asked ...will add the integers [1,20], which unambiguously states that the range is inclusive of 1 and 20.
    – Gnawme
    Oct 26, 2011 at 23:53
  • 6
    @Terry On the contrary, it's a good way to introduce students to ambiguous requirements!
    – Hugo
    Oct 27, 2011 at 6:10

4 Answers 4


As a programmer, every usage of the between keyword I've seen would define 'between X and Y' as 'greater than or equal to X and less than or equal to Y'

An example would be the BETWEEN comparison operator in MySQL.

I would say your interpretation of 'between 1 and 20' to include the upper and lower bounds (1 and 20) is absolutely correct.

Having said that, it could certainly be more clearly worded. For starters, adding 'the numbers' between 1 and 20, or even 1 and 1.000000001, would be an endless task. They should specify integers at the very least, as well as using a less ambiguous definition of the boundaries such as suggested by @MetaEd (+1).

  • 2
    If you want to be 100% clear, you can say "between 1 and 20 (inclusive)." But I think it's already 100% clear. In common English, between for integers and countable objects is inclusive. Oct 26, 2011 at 21:42

In the context of a programming class, it is particularly important to avoid ambiguity about the input. In this case, between could mean the numbers 2 through 19. Perhaps try

… which computes the sum of the numbers 1 through 20.

  • Don’t you wish there were just one single personal style sheet somewhere that you could change, and these would all just magically fix themselves?
    – tchrist
    Aug 8, 2012 at 2:04
  • Yes. More generally I think it would be nice to have a house style. Style can help or hinder a person’s understanding of a text, and there are a lot of rather poor stylings on the site.
    – MetaEd
    Aug 8, 2012 at 2:06

I imagine that you're interpreting it the way it was intended, but it should have been worded more clearly. Perhaps "add the integers from 1 through 20, inclusive."


Since it's a relatively ambiguous question that you have to solve, the appropriate thing to do is comment your code with your assumptions. In general, commenting ambiguity, or anywhere where you have questions, is best practice.

Here, the ambiguity is the range of numbers. Is it [1,20], i.e. inclusive? (Probably.) But it could also be (1,20) (exclusive), or a mix, e.g. [1,20). In fact, many loop or range functionalities expect an input of the form [x,y)!

Ambiguity? Comment the shit out of it, if you'll pardon my segue to french.SE!

If you get the code and your assumptions right, then you have clean, clear code and you'll be making best practice into routine. Programmers will love you forever if you comment your code. We almost don't care about it working, by comparison, as long as there's some English there so we can follow your lead.

If your answer isn't what is expected, many courses will hand the code off to grad students to look at. If your comments detail your work so that they can understand it, and your code did what you thought it did, you often get at least some credit. This means that if your code is right but your assumptions are wrong, you're only faulted on your assumptions, and you get credit for writing code that does what you want.

  • Actually the appropriate thing to do is ask the teacher what they meant. Nailing down accurate requirements is a vital part of software engineering.
    – Jim Balter
    Aug 14, 2014 at 20:24
  • I was assuming that the OP was asking us because they couldn't reach their professor.
    – rsegal
    Aug 14, 2014 at 21:55
  • 1
    That might be the case or it might not. Regardless, in many cases people don't ask their professors, or clients, or interviewers, or colleagues, etc. for clarification of the requirements when that's the first thing they should do.
    – Jim Balter
    Aug 15, 2014 at 0:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.