Computer Science, asked by muskaankhan29, 1 year ago

print all the disarium numbers between m to n ​

Answers

Answered by ayaan12396
2

Please become my follower .......I will solve all you java program doubts......

import java.util.Scanner;

public class Disarium

{

public static void main(String args[])

{

Scanner sc = new Scanner(System.in);

System.out.print("Input a number : ");

int num = sc.nextInt();

int copy = num, d = 0, sum = 0;

String s = Integer.toString(num);

int len = s.length();

while(copy>0)

{

d = copy % 10;

sum = sum + (int)Math.pow(d,len);

len--;

copy = copy / 10;

}

if(sum == num)

System.out.println("Disarium Number.");

else

System.out.println("Not a Disarium Number.");

}

}

Similar questions