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

My Learnings from FTC

In my journey, in FTC I learned many things and came across many different challenges. I had to overcome all of these challenges and I learnt a lot in the process.  One of the major things that I learnt was 3d designing. Before I had some minor knowledge of using Fusion 360 but I learnt a lot more during this competition. As the only 3d Designer in the team I had to design many of the major parts we needed for the competition. Here are a few of the things that I designed. Battery Holder To hold the battery to our robot, we needed a holder to store it and help us attach it to the robot. To start, I took the battery measurements by the scale and created a sketch to be the base, then extruded the walls and the base. I made a slot for the wire of the battery to be able to come out.  With the rough design of the battery holder down, I started the refinement of the build and filleted down all the sharp edges. However, if I were to re-design this part, I could count this step as a mistake as

Press mention for the International success at MAKEX 2022

Report on ‘The Goan’ https://www.thegoan.net/tg-life/%EF%BB%BFmaking-india-proud-goan-kids-play-robot(ic)s-on-international-stage/92358.html Report on TOI Goa https://timesofindia.indiatimes.com/city/goa/goan-students-stand-second-at-international-robotics-event/articleshow/96207801.cms Report on Goa News https://goa.news/goan-students-stand-2nd-at-international-robotics-event

Brahma of Goa

Over the last few weeks, as a part of my participation in the E-Yantra Virtual Museum competition, I have been on a journey to discover the history of one statue and its entire story. I have scoured the internet searching for leads, visited temples, talked to priests and gone around Goa to find out about this one statue. This statue is a sculpture of Brahma, a Hindu god. It is chiselled black stone and originates in the Kadamba era (12th century). It is decorated with many details, stands tall, and is bearded with Kadamba-style designs. The figure carries a ladle in its upper right Hand, The Vedas in its upper left hand. Kamandal in its lower left hand and chanting beads in its lower right hand.  Now let me walk you through my story about this statue. First, I saw images of the statue and then tried searching for information on it online. I found a few excellent articles, but those still wouldn’t give the full details. After a lot of scouring around the internet, I found one article w