+ 5
How to find All the DISARIUM no. Between 1 to 1000
518 is a disarium no. { i.e. 518 = 5(index 1) + 1 ( index 2) + 8 ( index 3)}
3 Respostas
+ 4
A disarium number is the sum of all of its digits to each digits indexes exponent.
I.E 518
5^1 + 1^2 + 8^3 = 518
public class Program
{
public static void main(String[] args) {
for(int i = 1; i < 1001; ++i) {
int num = i, x = 0, temp;
int length = getNumberOfDigits(i);
for(int j = 0; j < length; ++j) {
temp = num % 10;
num /= 10;
x += (int)Math.pow(temp, length-j);
}
if(i == x) {
System.out.println(i);
}
}
}
static int getNumberOfDigits(int number) {
int length = 1;
while((number /= 10) != 0){
++length;
}
return length;
}
}
outputs:
1
2
3
4
5
6
7
8
9
89
135
175
518
598
+ 5
Thx . i have got the answer . before some time .