On this page
Count the ways to fill a rhythm with short beats worth 1 and long beats worth 2, and you get 1, 2, 3, 5, 8, 13 and so on. In Europe these are called Fibonacci numbers. Indian poets and grammarians were counting them centuries before Leonardo of Pisa, because they needed to know every possible rhythm a line of verse could take. Our post on Fibonacci and the Liber Abaci gives the European story. This post looks at one of the Indian writers who stated the rule, the 12th-century prosodist Hemachandra (also spelt Hemacandra), and at the other counting rules in the same chapter of his book.
Who was Hemachandra and what did he write?
Hemachandra wrote the Chandonushasana, a treatise on metre. Jayant Shah of Northeastern University, in A History of Pingala's Combinatorics, dates it to about 1150 CE and works from the edition by H. D. Velankar (Bharatiya Vidya Bhavan, 1961). Shah translates the verses in Hemachandra's eighth chapter that deal with the six standard counting problems of Indian prosody: listing all forms, finding a form from its position, finding the position of a form, counting forms with a given number of short syllables, counting all forms, and the space needed to write the list.
The historian Parmanand Singh's paper in Historia Mathematica, The so-called Fibonacci numbers in ancient and medieval India (1985)90021-7), makes the larger point in its title: the sequence was known in India well before it carried a European name.
What is a matra metre?
Shah explains the two ways Indian prosody measured a line. Some metres fix the number of syllables. Others fix the total length in matras, a unit of time: a short syllable (L) counts 1 matra and a long one (G) counts 2. In a matra metre only the total time is fixed, so a line of 6 matras could be GGG, LLLLLL, LGLG and many more. Shah notes that much of the work on matra metres came later than Pingala, at the hands of prosodists writing about Prakrit verse.
What is Hemachandra's rule?
Shah translates verse 8.16 of the Chandonushasana as saying that adding the last count and the one before it gives the number of forms for the next matra count. He adds that this is the rule S(n) = S(n − 1) + S(n − 2) that Virahanka had given earlier. Hemachandra did not invent the rule, but his statement of it is one of the clear medieval sources.
Worked example: forms of 6 matras. Every form ends in either L or G.
If it ends in L (1 matra), the rest is a form of 5 matras.
If it ends in G (2 matras), the rest is a form of 4 matras.
So S(6) = S(5) + S(4). Starting from S(1) = 1 (just L) and S(2) = 2 (LL or G):
S(3) = 2 + 1 = 3: LLL, GL, LG
S(4) = 3 + 2 = 5
S(5) = 5 + 3 = 8
S(6) = 8 + 5 = 13
S(7) = 13 + 8 = 21
What other counting rules did he give?
Multi-foot metres. Shah translates verse 8.15 as saying that the number of forms of a matra metre made of several feet is the product of the number of forms of each foot. A line of four feet, each of 4 matras, therefore has 5 × 5 × 5 × 5 = 625 forms. This is the multiplication principle you use in permutations and combinations.
Verses with four quarters. A classical stanza has four quarters. Shah explains that it is sama (equal) if all four have the same pattern, ardhasama (half-equal) if the odd quarters match each other and the even quarters match each other but the two pairs differ, and vishama (unequal) otherwise. In Shah's translation, Hemachandra counts the ardhasama forms as the square of the sama count minus the sama count, and the vishama forms as the square of that square minus the original square.
Worked example: quarters of 8 syllables. Each syllable is L or G, so one quarter has 2⁸ = 256 patterns, and there are 256 sama stanzas.
Ardhasama: choose the odd-quarter pattern (256 ways) and the even-quarter pattern (256 ways), giving 65,536, then remove the 256 cases where they are the same. 65,536 − 256 = 65,280.
Vishama: all four quarters chosen freely gives 256⁴ = 4,294,967,296. Remove every stanza where odd and even pairs each match, which is 256² = 65,536 (this includes the sama ones). 4,294,967,296 − 65,536 = 4,294,901,760.
The rule is an early example of counting by subtracting the cases you do not want.
Which mistakes does this help you avoid?
Counting syllables instead of matras. GGG has 3 syllables but 6 matras. Decide which length the problem fixes before you start.
Getting the starting values wrong. S(1) = 1 and S(2) = 2. If you start 1, 1 you are counting something slightly different, and every later answer shifts by one place.
Subtracting twice. In the vishama count, the 65,536 already includes the sama stanzas. Removing the 256 again would undercount.
Our post on Pingala's metres and binary-style counting shows the older rules for listing and indexing patterns that Hemachandra's chapter builds on.
What can a student take from Hemachandra?
He worked in a tradition where each writer restated, checked and extended the rules of earlier ones. Shah notes, for example, that later prosodists mostly adopted Mahavira's powers-of-two method for finding a pattern's position, while Hemachandra kept a different one. Knowing more than one route to the same count is useful: in an exam, a second method is the fastest way to check the first.
If recurrences or the multiplication principle still feel shaky, the Fermi Concept Library covers every concept in physics, chemistry, biology, mathematics and computing, so you can revisit one idea at a time.
Try it now: count the forms of 8 matras with the recurrence, then list the ones that contain exactly two long syllables and check how many there are.



