Pingala (1800 BCE) of Chandasastra pioneered the mathematical study of meters. He developed advanced mathematical concepts for explaining prosody and its characteristics. Pingala was the first to establish the relationship between the theory of poetic rhythm and combinatorics much earlier than Marin Mersenne (1588-1648 AD) a French music theorist. Shārgadeva, a Kashmiri Pandit, authored Sangitaratnākara which is a greatest treatise on Indian music (vocal & instrumental) and dance after Bharata’s Nātya Shāstra. His grandfather, Bhāskara was a Kashmiri Brāhmin and Ayurveda scholar. Yādava King Bhillama (523-530 AD) invited Bhāskara to his capital Devagiri and appointed him as Rājavaidya or royal physician. Bhāskara’s son Sodhala became Accountant-General in the court of King Bhillama. Shārgadeva was the son of Sodhala and also became Accountant-General in the court of Yādava King Singhana (541-585 AD). In his Sangitaratnākara, Shārngadeva defined almost 264 rāgas as combination of swaras. He mathematically analyzed the permutations and combinations of swaras. He classified rāgas as Janaka rāga (parent rāga) and Janya rāga (child rāga). Seven basic swaras i.e. must be used once in Ārohanam (ascending order) and also, the seven swaras must be used once in Avarohanam (descending order) in every Janaka rāga. Each Janaka rāga can have many Janya rāgas derived from them but Janya rāga need not use seven swaras compulsorily in ascending and descending orders. He also mapped 22 shruti (octave) into seven swaras. Shārngadeva worked extensively on the subject of permutations and combinations. He described various algorithms to list all permutations and combinations of seven swaras and notes. Shārngadeva mentioned a method of singing called “Merukhanda” which consists of varied permutations and combinations of swara patterns. Merukhanda is a mathematically sequenced prastāra of all 5040 swara patterns (7×6×5×4×3×2×1 = 5040) that can be generated from seven swaras. Actually, these combinations of swaras are factorial and can be derived mathematically. According to Shārngadeva, the 1st row of prastāra of seven swaras starts with the natural order of swaras as s,r,g,m,p,d,n and the last 5040th row ends with the reverse order as n,d,p,m,g,r,s. He gave a mathematical formula (as shown in image) for the construction of intermediate rows. Interestingly, the algorithms described by Shārngadeva are now being used in computer programming.