What is the meaning of "exclusive" and "inclusive" when describing ranges of numbers?

A simple question, but I see exclusive and inclusive when I refer to ranges of numbers.

For example, this is a line from the book of algorithms:

The following function prints power 2 from 1 to n (inclusive).

What is meant by this? What makes a range of rooms included or exclusive?

+4
source share
2 answers

The following function prints power 2 from 1 to n (inclusive).

This means that the function will calculate 2^iwhere i = 1, 2, ..., n, in other words, it ican have values ​​from 1 to and include a value n. ie n Included in Inclusive

, , :

2 1 ().

, i = 1, 2, ..., n-1, .. i n-1, n, , i = n-1 - , . n n .

+9

Computer Science / , (, ):

1 through 10 (inclusive)
1 2 3 4 5 6 7 8 9 10

1 through 10 (exclusive)
1 2 3 4 5 6 7 8 9

2 :

[1, 10]
[1, 10)

:

  • Inclu sive - Inclu ding
  • Exclu sive - Exclu ding
+11

Source: https://habr.com/ru/post/1651632/


All Articles