Home Articles Sci-Tech KaTaPaYaDi - World's Oldest Hashing Algorithm

KaTaPaYaDi – World’s Oldest Hashing Algorithm

A hash is a numeric value that can be computed from a given piece of text. Modern computers use hashes because it is faster to compare numbers than text in computers. So all applications, databases, etc store text in the form of hashes and compare the hashes first while comparing the texts.

A hashing algorithm is any method that is used to convert text into a number. For example, we can have a simple hashing algorithm where each alphabet represents a number, like A=1, B=2, C=3 etc. In this case, the hash of CAB becomes 312.

In ancient India, a similar method existed to convert numbers into text – it was called the Katapayadi Sankhya scheme. Note that converting numbers into text is the reverse process of hashing. So, under the Katapayadi scheme each consonant was assigned a number. See the chart below.

प(Pa) =1फ(Pha)=2ब(Ba)=3भ(Bha)=4म(Ma)=5

The rule was any numeric sequence could be represented using the above table. Note that a single digit has multiple possible consonant values. So this flexibility allowed one to create meaningful word combinations that are easy to memorize, so this was a great mnemonic tool. One could create an infinite number of mnemonics to represent any numeric sequence using Katapayadi!

The name Katapayadi as you can see is derived from the consonants that have a value of 1 in the algorithm i.e. Ka, Ta, Pa, Ya.

Katapayadi as a mnemonic creating algorithm

गोपीभाग्यमधुव्रात-श्रुग्ङिशोदधिसन्धिग ॥  
खलजीवितखाताव गलहालारसंधर ॥

The above is a verse that is written in praise of Krishna and it means

Oh Krishna, the fortune of the Gopis, 
the destoryer of daemon Madhu, protector of cattle, 
the one who ventured into the ocean-depths, 
destroyer of evildoers, one with plough on the shoulder 
and the bearer of nectar, may (you) protect (us)!

Please note that this is not an ancient hymn as many think, but a recent one probably composed by Bharati Krishna Tirthaji. However, what this hymn shows is the amazing power of the Katapayadi scheme when combined with the beautiful grammar of Sanskrit that makes creating great combinations of meaningful words.

By applying the Katapayadi scheme to the above verse and reversing the digits, we get the sequence 314159265358979324. This is the value of pi to 17 decimal places with the last digit rounded off!! So, the beauty of the Katapayadi system is you can remember a large mathematical value as a hymn in praise of your favorite deity!

Ok, but why did we have to reverse the digits? That is because, in ancient India, in Sanskrit, the numbers are written in the reverse order of what we write today, like 123 is written as 321. So to read it in the order we use today, the numbers had to be reversed.

The table of trigonometric sines of angles constructed by the famous mathematician and astronomer from Kerala, Madhava, in the 14th century is also written in Katapayadi scheme! In other words, you learn a few lines of text, and then you know the trigonometric sine values of different angles!

Katapayadi as a hashing algorithm

The most famous use case that has applied Katapayadi scheme as a hashing algorithm is the classical Indian music system where the 72 base melakartha ragas are named such that, just by looking at the first two consonants in the name of the Raga one can quickly compute the Raga number!

But why should we compute the number of a raga? Because, the raga number is designed such that, using the Raga number one can find out the notes (Swaras) of that raga! So, the Katapayadi based naming of the melakartha ragas enables one to identify all the notes of that raga by just looking at its name!

This is one of the earliest and probably very few applications of hashing algorithms outside the world of computers. The names of the ragas are like a hash table.

Consider the raga Mayamalavagowla. Its first two consonants are M and Y. The value of M is 5 and that of Y is 1 in the Katapayadi Sankhya scheme. Note that in the Indian system numbers are written in the reverse order. So, the number we have here is 15 and 15 is the melakartha number of Mayamalavagowla!! As simple as that.

So the students of classical music in India learn the Katapayadi scheme and this helps them to quickly identify the Raga number and hence the notations of that raga. As you guessed, there is another rule that helps one arrive at the raga notations using the raga number. That is for another article another day :)

Oldest known use of Katapayadi algorithm

Vararuchi is a famous astronomer from the India state of Kerala who lived in 4th century. He is also the author of Chandravakyas (meaning lunar sentences). It contains the longitudes of the Moon at different intervals of time and these numbers are encoded using the Katapayadi system. This being the oldest known work using Katapayadi algorithm, it is believed that Vararuchi himself was the inventor of this algorithm.

Content Protection by DMCA.com

Download HitXP Mobile App

Get it on Google Play
Gurudev is the developer of Gurunudi AI Platform. This is his official website where he pens his thoughts on a wide range of topics, answers queries, shares resources and tools developed by him.


  1. Well Mr gurudev I didn’t get what’s total significance of it, is it in music, maths or symbolisation? can you give some references so to read more, in hindi or english?

    • Dr Shailesh, it is about representing text in the form of a unique number because in computing comparing numbers is faster than comparing text, and this technique is used by search engines today to make search faster. The fact is this technique was first used in ancient Indian classical music system to give a unique number to each raga so that by just knowing the raga name one would be able to tell its number and by knowing the number one can derive the swara sthanas of that raga!

  2. Yes sir, it is not vedic. The first documented reference for this system is available in the works of Aryabhatta where he used this system to represent numbers.


Please enter your comment!
Please enter your name here

RSS FeedSubscribe
Sound CloudFollow

Latest Articles

The Power of Democracy: How Free Societies Foster Innovation in Science and Technology

Democracy allows freedom of speech and thought, boosting creativity and innovation. This leads to scientific breakthroughs and technological advancements.

How does GOD helps us?

Do prayers really help? Do miracles happen when we are in trouble? Does God really help us in times of need? Are prayers enough to save us during bad times? How should we face problems?

Sanskrit poem on Ramayana – read in reverse becomes Mahabharata!

A Sanskrit poem about Ramayana when read in reverse direction becomes a poem on Mahabharata!

The difference between Itihasa and Puranas

Documentation of ancient Indian history and the historical events of Indian civilization in the form of Itihasa and Puranas - Ramayana and Mahabharata.

Latest Music Notations

Jai Shri Ram – Adipurush – Piano Notations

Piano, Keyboard, Violin, Flute notes, Guitar Tabs and Sheet Music of the Song Jai Shri Ram from the 2023 Hindi movie Adipurush in Western and Indian Notations.

Sojugada Soojumallige – Garuda Gamana Vrishabha Vahana – Piano Notations

Piano, Keyboard, Violin, Flute notes, Guitar Tabs and Sheet Music of the Song Sojugada Soojumallige from the 2021 Kannada movie Garuda Gamana Vrishabha Vahana in Western and Indian Notations.

Oo Antava Mava – Pushpa – Piano Notations

Piano, Keyboard, Violin, Flute notes, Guitar Tabs and Sheet Music of the Song Oo Antava Mava from the 2022 Telugu movie Pushpa in Western and Indian Notations.

Kaa Chalige Bangalore (Tiningaa Miningaa Tishaaaa) – Salaga – Piano Notations

Piano, Keyboard, Violin, Flute notes, Guitar Tabs and Sheet Music of the Song Tiningaa Miningaa Tishaaaa (Kaa Chali Ge) from the 2022 Kannada movie Salaga in Western and Indian Notations.
Content Protection by DMCA.com