A magic number is that number whose sum of its digits is when multiplied by the reverse of the sum of its digits gives back the same number.

Magic number in Python

Steps to Check Magic Number in Python

  1. Take a number as input (num).
  2. Calculate the sum of digits of the input number.
  3. Reverse the calculated sum.
  4. Multiply the reverse and sum of digits of the input number.
  5. If the result of the multiplication is equal to the original input number, then its magic number else not.

Check Whether a number is a Magic Number in Python


Find all the Magic Numbers in the interval in Python

Any doubts then comment below.

Leave a Reply

Close Menu