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
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


Subscribe to HitXP Articles

To be updated with all the latest articles, offers and special announcements.

Latest Articles

Corona Virus, SARS – Why are new viruses increasingly originating from China?

The reason why new strains of deadly viruses are emerging from China. Viruses like coronavirus and SARS should be stopped from evolving and spreading to prevent another global pandemic.

Evolution of life – primitive cells, complex organisms, intelligence, what next after humans?

Evolution of life from primitive life forms to complex multi cellular organisms to intelligent human species - the advent of AI raises a natural question - What next after human?

The individual human is smart, but the human species is dumb

The smart individual human has to clean up the mess created by his dumb species. Species polluted the planet, individuals are cleaning it up.

What if Dinosaurs did not go extinct 65 million years ago?

Imagine a world where dinosaurs did not go extinct, because that asteroid missed colliding with Earth. How would have life evolved then?
Content Protection by DMCA.com