Home / Reasoning / Repeating Patterns: Find the 20th or 100th Item
Reasoning & Coding · Patterns
Repeating Patterns: Find the 20th or 100th Item
Find the core of a repeating pattern, use its length and the remainder to name the 20th or 100th item, count items and trace a short program.
The idea
A string of beads goes red, blue, blue, red, blue, blue, and keeps going. What colour is the 100th bead? You do not need to draw 100 beads. A repeating pattern has a core: the shortest group of items that repeats over and over. Here the core is red, blue, blue, and the core length is 3.
To find the core, look for the shortest group that repeats exactly, and check it against the whole pattern. The core of A B B A B B A B B is A B B. The pattern may stop in the middle of a core, so A B B A B B A has a core of A B B, not A B B A.
To extend a pattern, keep writing the core. That works for the next few items, but it is slow for the 20th item and very slow for the 100th. A faster way uses division. Divide the position by the core length and look at the remainder. The remainder tells you which item of the core the position lands on.
Here is the rule. Divide the position by the core length. If the remainder is 1, it is the 1st item of the core. If the remainder is 2, it is the 2nd item, and so on. If the remainder is 0, the position finishes a core exactly, so it is the last item of the core. Example: core A B C, 20th item. 20 ÷ 3 = 6 remainder 2, so the 20th item is the 2nd item of the core, B.
The quotient (the 6) is useful for something else: it counts complete cores. To count how many of one item are in the first 20 items, multiply the number of complete cores by how many times the item appears in one core, then check the leftover items at the end.
Programmers write the remainder as n mod L, which means the remainder when n is divided by L. The computer step “r = n mod 3” gives 2 when n = 20. Many programming languages number list items from 0, so they use (n − 1) mod L to get the position. In this lesson we count from 1 and treat a remainder of 0 as the last item. Both ways give the same answer.
Worked examples
Example 1 · Find the core and its length
What is the core of this pattern, and how many items does it have?
- Read from the left and find the shortest group that repeats exactly: A, B, B.
- Check it: A B B, then A B B, then A B B, and the pattern ends with the start of another core (A).
- The core is A B B. It has 3 items, so the core length is 3.
The core is A B B and the core length is 3.
Example 2 · The 20th item with a remainder
The core is A B C and it repeats forever. What is the 20th item?
- The core length is 3, so divide the position by 3: 20 ÷ 3 = 6 remainder 2.
- The 6 means 6 complete cores are used up (18 items). The remainder 2 means the 20th item is the 2nd item of the next core.
- The 2nd item of A B C is B. Check: the 18th item is C, the 19th is A and the 20th is B.
The 20th item is B.
Example 3 · When the remainder is 0
The core is A B C D. What is the 100th item?
- The core length is 4: 100 ÷ 4 = 25 remainder 0.
- A remainder of 0 means the 100th item finishes the 25th core exactly. It is the last item of the core, not the first.
- The last item of A B C D is D. The same is true for positions 4, 8, 12 and every other multiple of 4.
The 100th item is D.
Example 4 · Count how many in the first 20
The core is R R B. How many R items are in the first 20 items?
- Core length 3: 20 ÷ 3 = 6 remainder 2. That is 6 complete cores and 2 leftover items.
- Each core has 2 R items, so 6 cores have 6 × 2 = 12 R items.
- The 2 leftover items are the first 2 items of the core, R and R, which adds 2 more: 12 + 2 = 14.
14 R items.
Example 5 · A short program that finds any item
Trace the program. What does it say? core = A, B, C, D, E. n = 47. r = n mod 5 (the remainder when 47 is divided by 5). If r = 0, say the last item of core; otherwise, say item number r of core.
- The core has 5 items, so the program divides by 5: 47 ÷ 5 = 9 remainder 2, so r = 2.
- r is not 0, so the program says item number 2 of the core.
- Item 2 of A, B, C, D, E is B. The program never writes out 47 items; it jumps straight to the answer.
It says B.
Common mistakes
Why this fails: In 20 ÷ 3 = 6 remainder 2, the 6 counts complete cores. Only the remainder 2 tells you where you are inside the core.
Why this fails: A remainder of 0 means the position lands exactly at the end of a core, so it is the last item. Position 100 with core length 4 is the 4th item of the core.
Why this fails: The first item of the pattern is item 1. If you count from 0 you are one item off, and every answer shifts to the neighbouring item in the core.
Why this fails: In A B C A B, the group A B C A B does not repeat in full. Find the shortest group that repeats exactly, here A B C, and check it against the whole pattern.
Why this fails: Complete cores are not always the whole story. With 20 items and a core of 3, there are 2 leftover items at the end, and they might hold the item you are counting.
Foundation
Foundation practice
Find the core, then use the remainder to name an item.
1. What is the core of a repeating pattern?
- The first item of the pattern
- The shortest group of items that repeats exactly
- The whole row you can see on the page
- Any group of three items in a row
2. How many items are in the core of this pattern?
- 2
- 4
- 12
- 3
3. What is the next item (the 11th) in this pattern?
- C
- D
- A
- B
4. The core is A B C and it repeats forever. What is the 8th item?
- C
- A
- B
- 2 (the quotient)
5. The core has 4 items. For position 22: 22 ÷ 4 = 5 remainder 2. Which item of the core is the 22nd item?
- The 5th item of the core
- The 2nd item of the core
- The 4th item of the core (the last item)
- The 22nd item of the core
Practice
Practice practice
Use the remainder for far positions, including a remainder of 0.
6. Here is a pattern: 2, 4, 4, 2, 4, 4, 2, 4, 4, 2. Starting at the first item, what is the core?
- 2, 4
- 2, 4, 4, 2
- 2, 4, 4
- 4, 4, 2
7. The core is A B C and it repeats forever. What is the 20th item?
- B
- C
- A
- The 6th item of the core
8. The core is red, blue, green, yellow. What is the 100th item?
- red
- blue
- green
- yellow
9. The core has 5 items. Which list shows only positions that are the last item of the core?
- 6, 11, 16, 21
- 5, 10, 15, 20
- 4, 9, 14, 19
- 1, 5, 9, 13
10. The core is A A B. Use division to find the 50th item. Write the division with its remainder and name the item.
11. The core is R R B. How many R items are in the first 20 items?
- 12
- 13
- 14
- 15
Challenge
Challenge practice
Trace programs, use the 7-day week and fix wrong reasoning.
12. What does the program say? core = R, B, Y. n = 50. r = n mod 3. If r = 0, say the last item of core; otherwise, say item number r of core.
- R
- B
- Y
- It says 16
13. Today is Friday. The days repeat Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday. What day of the week will it be 30 days from today?
- Saturday
- Tuesday
- Friday
- Sunday
14. Sam says: “The core is X Y Z. 28 ÷ 3 = 9 remainder 1, so the 28th item is the 9th item, which is Z.” What did Sam do wrong?
- He used the quotient 9 as the position, not the remainder 1
- His division was wrong, because 28 ÷ 3 is 9 remainder 2
- The core length should be 28, not 3
- A remainder of 1 means the last item of the core
15. Pattern A has a core of 3 items. Pattern B has a core of 4 items. Both start at the first item of their cores at position 1. After position 1, what is the first position where both patterns start a core again at the same time?
- 12
- 7
- 13
- 25
16. A list is numbered core[0], core[1], core[2], so it has a core of 3 items and starts counting at 0. Which formula gives the list number of the nth item of the pattern, where n starts at 1?
- n mod 3
- n ÷ 3
- (n + 1) mod 3
- (n − 1) mod 3
Answer key
- 1. The shortest group of items that repeats exactly
The core is the shortest group that repeats exactly. The first item alone is only part of it, the whole row on the page can stop partway through a core, and a group that does not repeat in full is not a core. - 2. 3
The shortest group that repeats is R B B, which has 3 items. Choosing 2 counts only the different letters (R and B). Choosing 4 stops at R B B R and wrongly treats the next R as part of the core. Choosing 12 counts the whole row. - 3. C
The core is A B C D. The 10th item, B, is the 2nd item of the third core, so the 11th item is the 3rd item of the core, C. Choosing D skips ahead by one. Choosing A or B restarts the core too early. - 4. B
8 ÷ 3 = 2 remainder 2, so the 8th item is the 2nd item of the core, B. Writing it out gives A B C A B C A B, and the 8th is B. Choosing C counts one item too far (counting from 0). Choosing A is the first item, which is what you get if you forget the leftover after the 2 complete cores. Choosing 2 is the quotient, which counts complete cores and is not an item. - 5. The 2nd item of the core
The remainder 2 says the 22nd item is the 2nd item of the core. The 5 only counts complete cores (20 items). Choosing the 5th item uses the quotient, which is not even in a core of 4. Choosing the 4th item treats the position as a multiple of 4. Choosing the 22nd item ignores the repeating. - 6. 2, 4, 4
The shortest group that repeats exactly is 2, 4, 4 (3 items): 2, 4, 4 | 2, 4, 4 | 2, 4, 4 | 2. The group 2, 4 does not repeat, because the third item is 4, not 2. The group 2, 4, 4, 2 is longer than the core and its copies would not line up. The group 4, 4, 2 does not begin at the first item. - 7. B
20 ÷ 3 = 6 remainder 2, so the 20th item is the 2nd item of the core, B. Choosing C counts one too far: the 21st item is C. Choosing A is the answer for the 19th item (remainder 1). Choosing the 6th item uses the quotient, and the core has only 3 items. - 8. yellow
100 ÷ 4 = 25 remainder 0, so the 100th item ends the 25th core exactly. It is the last item of the core, yellow. Choosing red treats a remainder of 0 as the start of a core. Choosing blue or green uses a neighbouring position. - 9. 5, 10, 15, 20
The last item of a 5-item core lands on every multiple of 5, where the remainder is 0: 5, 10, 15, 20. The list 6, 11, 16, 21 is the first item of the core (remainder 1). The list 4, 9, 14, 19 is the 4th item (remainder 4). The list 1, 5, 9, 13 jumps by 4, which is not the core length. - 10. 50 ÷ 3 = 16 remainder 2, so the 50th item is the 2nd item of the core, A.
Core length 3. 50 ÷ 3 = 16 remainder 2, so the 50th item is the 2nd item of A, A, B, which is A. A good answer shows the division, the remainder and which core item it picks. Check: the 48th item ends a core with B, the 49th is A and the 50th is A. - 11. 14
20 ÷ 3 = 6 remainder 2. Six complete cores hold 6 × 2 = 12 R items. The 2 leftover items are R and R, so add 2 more: 14. Choosing 12 forgets the leftover items. Choosing 13 counts only one of the leftover items. Choosing 15 adds a third R that is not there. - 12. B
50 mod 3 is 2, because 50 = 16 × 3 + 2. Since r is not 0, the program says item 2 of R, B, Y, which is B. R is what you get with r = 1 (position 49) and Y is what you get with r = 0 (position 51). The program does not say 16, because 16 is the quotient and the quotient is not an item. - 13. Sunday
The days repeat with core length 7. 30 ÷ 7 = 4 remainder 2, so 30 days from Friday is 2 days after Friday: Saturday, then Sunday. Choosing Saturday counts only 1 day for the remainder. Choosing Tuesday uses the quotient 4 as the number of days to move. Choosing Friday forgets the remainder. - 14. He used the quotient 9 as the position, not the remainder 1
Sam read the 9 (complete cores) as the position. The remainder is 1, so the 28th item is the 1st item of X Y Z, which is X. Sam's division was right, so the answer is not that 28 ÷ 3 is wrong. The core length does not need to change, and a remainder of 1 does not mean the last item. - 15. 13
Pattern A starts a core at positions 1, 4, 7, 10, 13. Pattern B starts a core at 1, 5, 9, 13. The first match after 1 is 13. Choosing 12 uses the common multiple of 3 and 4 but forgets that cores start at 1, 4, 7, not at 3, 6. Choosing 7 adds 3 + 4. Choosing 25 is a later match, not the first. - 16. (n − 1) mod 3
For n = 1 we need core[0]: (1 − 1) mod 3 = 0. For n = 3 we need core[2]: (3 − 1) mod 3 = 2. For n = 4 the pattern restarts: (4 − 1) mod 3 = 0. The formula n mod 3 gives 1 for n = 1, which skips core[0], and gives 0 for n = 3, which picks core[0] when core[2] is needed. The formula n ÷ 3 gives the number of cores, not a position. The formula (n + 1) mod 3 gives 2 for n = 1, which is also off.