A construction for any antima m and sthāna n, not just m = n = 3.
What the entries are, and why the flag takes this shape.
International Conference on the History of Indian Mathematics 2026
Prasad Jawalgekar · Bhumika Mittal · K. Ramasubramanian · Aalok Thakkar
The full text surfaced only in the twentieth century, when Padmākara Dvivedī found a complete manuscript in his father Sudhākara's collection and printed it in two volumes, 1936 and 1942.
अथ गणकानन्दकरं सङ्क्षेपादङ्कपाशकं वक्ष्ये ।
निपतन्ति यत्र मत्सरवन्तो दुष्टाः कुगणका ये ॥
atha gaṇakānandakaraṃ saṅkṣepādaṅkapāśakaṃ vakṣye | nipatanti yatra matsaravanto duṣṭāḥ kugaṇakā ye ||
I now introduce aṅkapāśa, which delights mathematicians, and where the jealous, wicked, and incompetent (kugaṇaka) suffer a fall. A pun, śleṣa: the subject of combinatorics, and a net of numbers that traps bad mathematicians.
He then lists where it applies, across six different fields:
How do we construct a patākā for any give antima and sthāna?
A construction for any antima m and sthāna n, not just m = n = 3.
What the entries are, and why the flag takes this shape.
आदौ रूपं विलिखेत् अन्तिमगुणितं पुरः पुनस्तद्वत् ।
स्थानाधिकं तु यावत् पङ्क्तिर्गुणकोत्तराख्येयम् ॥
ādau rūpaṃ vilikhet antimaguṇitaṃ puraḥ punastadvat | sthānādhikaṃ tu yāvat paṅktirguṇakottarākhyeyam |
Powers of m: G(m, n) = 1, m, m2, …, mn.
For m = 3: 1, 3, 9, 27, the corners that close each stage.
स्थानाहतोऽन्तिमाङ्कः सैकः स्थानोनितश्च तच्छेषम् ।
आभ्यासिक्यां पङ्क्तौ प्रजायते स्थानमानमिह ॥
sthānāhato'ntimāṅkaḥ saikaḥ sthānonitaśca taccheṣam | ābhyāsikyāṃ paṅktau prajāyate sthānamānam iha |
Multiples j·mr, in increasing order: the first-row values.
For m = n = 3: A = 1, 2, 3, 6, 9, 18, 27, the smallest number in each column.
What is the ābhyāsikī for m = 4, n = 3?
A = 1, 2, 3, 4, 8, 12, 16, 32, 48, 64.
अन्तिममितवैश्लेषस्थानाङ्कमिताश्च ताः पृथक् स्थाप्याः ।
तासां घातः सूचीपङ्क्तिर्नाराचिका वा स्यात् ॥
antimamitavaiśleṣasthānāṅkamitāśca tāḥ pṛthak sthāpyāḥ | tāsāṃ ghātaḥ sūcīpaṅktir nārācikā vā syāt |
Coefficients of (1 + x + ⋯ + xm−1)n.
For m = n = 3: (1 + x + x²)³ = 1 + 3x + 6x² + 7x³ + 6x⁴ + 3x⁵ + x⁶, so N = 1, 3, 6, 7, 6, 3, 1.
the numbers 1 to 27
each number, less one, in three base-three digits · 1 becomes 000, 27 becomes 222
add the three digits · the digit sum runs from 0 to 6
group by digit sum, keeping each group in increasing order
the patākā assembles itself · column heights 1, 3, 6, 7, 6, 3, 1
The patākā is an enumeration of [m]n.
All mn ways to fill n places with m symbols, each set in the column of its digit sum.
The same structure surfaces in the algorithm of the verses.
नाराचपङ्क्त्यङ्कमिताः कोष्ठानामूर्ध्वपङ्क्तयः । तिर्यग्गामी च सर्वासां स्वस्वखण्डावसानमा ॥
पङ्क्तौ तदाद्यकोष्ठे यः पल्लवोऽथाङ्कयोजनाः । तिर्यक्स्थितायामाद्यायां पङ्क्तिमाभ्यासिकीं लिखेत् ॥
तदन्तिमाङ्कः क्षेपाख्यः पुरःस्थः साध्यनामकः । क्षेपं पुरातनैरङ्कैः क्रमात् संयोजयेत् पृथक् ॥
तानधस्तिर्यग्गायां च कोष्ठपङ्क्त्यां विनिक्षिपेत् । साध्याङ्कस्य पताका स्यात् साध्यं क्षेपं प्रकल्पयेत् ॥
साध्यं पुरःस्थितं कृत्वा क्षेपं प्राग्वत् पुरातनैः । अङ्कैराद्यद्वितीयादिकोष्ठपङ्क्तिगतैर्युतम् ॥
तिर्यङ्निरङ्ककोष्ठेषु साङ्काधःस्थेषु विन्यसेत् । येनाङ्केन युतः क्षेपः साध्याङ्कादधिको यदा ॥
तदा मुक्त्वा तमङ्कं तु योजयेदितरांस्ततः ॥
पुरातनाङ्कः
purātanāṅka
the old number
A number already placed in the flag. Every new entry is built from one.
क्षेपः
kṣepa
the increment, j·3r
The current first-row term. Adding it raises one base-three digit by j, so the sum lands exactly j columns to the right.
साध्यः
sādhya
the bound
The next first-row term. Keep only sums below it: precisely the condition that no carry occurs.
Given antima m and sthāna n: write the ābhyāsikī along the first row, then fill the grid along the diagonals.
keep track of only three numbers
first row laid · K = 3, S = 6
साध्याङ्कस्य पताका स्यात् ।
sādhyāṅkasya patākā syāt |
The patākā is [the same] as the sādhya number.
Each closed stage is a complete smaller patākā. Raising n by one wraps the whole flag inside a larger one.
Patākā(m, n) ▷ antima m, sthāna n A ← ābhyāsikī(m, n) ▷ first-row values j·m^r write A along the first row K ← A[2]; S ← A[3] ▷ kṣepa (increment), sādhya (bound) repeat for each placed entry p, in order: if p + K < S: place p + K in the next diagonal cell ▷ column of p, shifted right by offset(K) K ← S; S ← next term of A until K = m^n return the grid offset(K) = j where K = j·m^r
Column k lists the indices of [m]n whose base-m digits sum to mn − k, in increasing order. The whole grid is built in Θ(n · mn) time, optimal for listing all mn indices.
Try it live: bhumikamittal.in/pataka-algo
Thank you
open for questions