AJ Java Programs Program 4: Disarium Number A number will be called DISARIUM if sum of its digits powered with their respective position is equal to the original number. For example 135 is a DISARIUM (Workings 1 1 +3 2 +5 3 = 135, some other DISARIUM are 89, 175, 518 etc) Syntax: import java.io.*; class disarium { public static void main(String args[])throws IOException { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); int n,n1,n2,c=0,sum=0,d=0; System.out.println("Enter a Num"); n=Integer.parseInt(br.readLine()); n2=n1=n; while(n2!=0) { n2=n2/10; c++; } ...
Comments
Post a Comment