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.

Download HitXP Mobile App on Google Play

Get it on Google Play
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

RSS FeedSubscribe
Sound CloudFollow

Latest Articles

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.

Online Education should be interactive and innovative – Fun to Learn

For online education to succeed for smaller classses - it should be as interesting as cartoons. Online education cant succeed unless it is more interesting, interactive and innovative than offline schooling.

The Complete List of Dhatus – Sanskrit Root Words and their English meaning

A complete list of all dhatus (root words or verb roots) in Sanskrit dictionary and their meanings with corresponding IPA transliteration.

Sanskrit Lesson 4 – Word Creation Magic using Dhatus

Learn how easy it is to create new words in Sanskrit using root words called Dhatus. This simple process of Sanskrit grammar powers the entire language.

Latest Music Notations

So Gaya Ye Jahan – Tezaab – Piano Notations

Piano, Keyboard, Violin, Flute notes, Guitar Tabs and Sheet Music of the Song So Gaya Ye Jahan from the 1988 Hindi movie Tezaab in Western and Indian Notations.

Background Theme (BGM) – Mouna Ragam – Piano Notations

Piano, Keyboard, Violin, Flute notes, Guitar Tabs and Sheet Music of the Song Background Theme (BGM) from the 1986 Tamil movie Mouna Ragam in Western and Indian Notations.

Dil Kya Kare Jab Kisi Se – Julie – Piano Notations

Piano, Keyboard, Violin, Flute notes, Guitar Tabs and Sheet Music of the Song Dil Kya Kare Jab Kisi Se from the 1975 Hindi movie Julie in Western and Indian Notations.

Albela Sajan Aayo Re – Hum Dil De Chuke Sanam – Piano Notations

Piano, Keyboard, Violin, Flute notes, Guitar Tabs and Sheet Music of the Song Albela Sajan Aayo Re from the 1999 Hindi movie Hum Dil De Chuke Sanam in Western and Indian Notations.

Download HitXP Mobile App on Google Play

Get it on Google Play
Content Protection by DMCA.com