Consider this sequence of numbers representing components on a page:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
Every set of 3 numbers makes up a page, with indexing restarting for each new page. Essentially, it follows column-based indexing.
You can visualize it as:
0 1 2
3 4 5
6 7 8
9 10 11
12 13 14
15 16 17
18 19 20
21 22 23
24 25 26
27 28 29
Where every row represents a page and each column represents a component.
The goal is to determine the specific page/row and component/column based solely on these numbers. Both pages and components are indexed starting from 0.
I have successfully identified the page index using Math.floor(number / 3)
, but how can I pinpoint the component?
For instance, 20
corresponds to component 2 on page 6, 10
signifies component 1 on page 3, and 27
indicates component 0 on page 9.