- Related Questions & Answers
- Python program to print all Happy numbers between 1 and 100
- Program to print numbers from 1 to 100 without using loop
- Java program to print prime numbers below 100
- How will you print numbers from 1 to 100 without using loop in C?
- Print 1 to 100 in C++, without loop and recursion
- Python program to print all even numbers in a range
- Python program to print all odd numbers in a range
- Python program to print all Prime numbers in an Interval
- Program to find all missing numbers from 1 to N in Python
- Write a program to append Magic Numbers from 1 to 100 in a Pandas series
- Java program to print the Armstrong numbers between two numbers
- How to print all the Armstrong Numbers from 1 to 1000 using C#?
- C Program to print numbers from 1 to N without using semicolon
- Python Program to Print Numbers in a Range (1,upper) Without Using any Loops
- Python Program to Print Numbers in an Interval

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

When it is required to print all the disarium numbers between 1 and 100, a simple loop can be run between 1 and 100 and the length of every number can be calculated, and the power of the position can be multipled with the number itself.

If they are equal, it is considered as a disarium number.

A Disarium number is the one where the sum of its digits to the power of their respective position is equal to the original number itself.

Below is a demonstration for the same −

def length_calculation(my_val): len_val = 0 while(my_val != 0): len_val = len_val + 1 my_val = my_val//10 return len_val def digit_sum(my_num): remaining = sum_val = 0 len_fun = length_calculation(my_num) while(my_num > 0): remaining = my_num%10 sum_val = sum_val + (remaining**len_fun) my_num = my_num//10 len_fun = len_fun - 1 return sum_val ini_result = 0 print("The disarium numbers between 1 and 100 are : ") for i in range(1, 101): ini_result = digit_sum(i) if(ini_result == i): print(i)

The disarium numbers between 1 and 100 are : 1 2 3 4 5 6 7 8 9 89

- Two methods are defined, that are used to find the number of digits in the number, and to get the product of the digit multiplied with its position.
- An initial result is assigned to 0.
- A loop is iterated over numbers between 1 and 101, (excluding 101), and if the number is same as the product of the digits in the number and the position, it is considered as a disarium number.
- This is displayed as output on the console.

Advertisements