Find Magic Number C Program

By | October 10, 2016

Learn how to Find Magic Number in C Programming. A Magic Integer is also known as Ramanujan’s Number. Find more about magic integers on Wikipedia. You must know how to Reverse the Digits of a Number and how to find the Sum of Digits of a Number to understand this program better.

What is a Magic Number?

Also known as Hardy-Ramanujan Number or Taxicab Number, it is an integer in which, when its digits are added, it produces a sum which, when multiplied by the its reversed number, fetches the original integer.

Must Read: C Program To Find if a Number is a Strong Integer or Not



8 + 1 = 9

9 × 9 = 81


1 + 7 + 2 + 9 = 19

19 × 91 = 1729

How To Check if an Integer is a Magic Number or Not?

  1. Fetch a Number from the User.
  2. Find Sum of Digits and Multiply it with the its Reverse.
  3. If the Product is same as the original number, it’s a Magic Number.


  1. Input a Number and store it in N.
  2. Find Sum of Digits of the Original Number and store it in A.
  3. Reverse the Digits of A and store it in B.
  4. Multiply A and B and store it in C.
  5. If C == N, then it is a Magic Integer.

Must Read: C Program To Find Sum of Two Complex Numbers


C Program To Check if a Number is a Magic Number or Not


Must Read: C Program To Check if Number is Narcissistic Number or Not


C Program To Find Magic Number using Functions

If you have any compilation errors or doubts in this code to find magic integers in c programming, let us know about it in the comment section below.

2 thoughts on “Find Magic Number C Program

  1. Prabhjot Singh

    This is just awesome! I just saw the movie – The Man Who Knew Infinity. Once G H Hardy and S Ramanujan were travelling on a motor vehicle and this was inscribed on the Number plate of that vehicle – CE 1729. Just see the brilliant minds and their calculations! It is astonishing. Good work!


Let's Discuss