Skip to main content

Coding Kaprekar Constants

Here is an interesting play with numbers. Take any three-digit number, for example 276, subtract its digits i.e. 276 in descending order by the digits in ascending order, e.g., 762–267 and keep repeating this process; eventually, it will reach a constant, namely 495.

Try this same method for a four-digit number and it will reach the number 6174. Try the same method for six digits, and we will arrive at two constants, i.e. 54994 and 631764, and one loop.

Interestingly this phenomenon was noted by an Indian Mathematician Dr Kaprekar in the year 1955, and these constants are called as Kaprekar constants. To know more about Kaprekar Constant you can watch this video

I challenged myself to code Kaprekar constant for all digits. I have made a code in python which finds all the 3,4, and 6 digit numbers that don’t follow the Kaprekar constant.

Run the Code in Replit:

https://replit.com/@Saipranavsg/Kaprekar-Numbers?v=1#main.py

Link to Medium Article https://medium.com/@saipranavsg/kaprekar-constants-bcb35a088788

Comments

Popular posts from this blog

AllergyAlly a mobile app

  AI-powered allergy companion app that revolutionizes allergy management. The mobile app was developed as part of submission to the  Global AI Hackathon  using the  MIT app inventor platform  by me and my teammate Viraj Marathe. UPDATE: The Allergy Ally app secured the Honourable Mention Award at the Global AI Hackathon. The World Allergy Organization estimates that 20–30% of the global population experiences some form of allergy. Impact on Quality of Life by Allergies: Missed days Poor Sleep Dietary Restrictions Mental Health Medical history remains a cornerstone in allergy diagnosis, guiding healthcare providers in making informed decisions and providing appropriate care to patients. And this app documents each and every allergic incident and provides detailed report for the healthcare providers with the help of AI. Existing solutions are not satisfactory and our mobile app Allergy ally acts as a companion to persons troubled by allergies. Features of the ap...

Certificate of Excellence from MIT app Inventor

I was elated to recieve the certificate from the App Inventor Foundation which states i have RECEIVED Honorable Mention IN THE Youth Team CATEGORY FOR THEIR APP AllergyAlly AS PART OF THE GLOBAL AI HACKATHON 2024.  I have earlier received recognition for my app VOX in 2021 from MIT app Inventor as well 

Chat GPT prompts for mobile app

I and my team mate have been working on building an AI-powered allergy companion app that revolutionizes allergy management ‘AllergyAlly’ The details about the mobile app can be viewed on medium post AllergyAlly AI-powered allergy companion app that revolutionizes allergy management medium.com Medical history remains a cornerstone in allergy diagnosis, guiding healthcare providers in making informed decisions and providing appropriate care to patients. And this app documents each and every allergic incident and provides detailed report for the healthcare providers with the help of AI This has been made possible by clever integration with chat GPT by using prompt engineering which makes the app seamless, easy and powerful. The various prompts used are Prompt for symptoms and triggers Log Analyses user submitted information about the allergic incidents, symptoms, triggers, mood etc and populates the log page of the app You are now a part of a large code. Your duty is to understand the in...