Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

BlueJ Program on Weak Arm Number



What is Weak Arm number


Weak arm numbers are those where the number is equal to the sum of the digits to the power 'n'. 'n' is the number of digits in the number and it is maximum for the unit digit value and decreases by one

 For example to check whether 153 is an Weak Arm number, the sum would be like 1 1+ 5 2 + 3 3. 153 is not weak arm number. Examples of weak arm numbers are 89, 135, 175, 518, 598


import java.io.*;
public class WA
{
void showWeakArm() throws Exception
{
 int c=0;
 int a,d,b,n;
 double sum=0;
BufferedReader br=new  BufferedReader(new InputStreamReader(System.in));
System.out.println("enter  the no.");
n=Integer.parseInt(br.readLine());
b=n;
while(b >0)
{
 c++;
 b=b/10;
}
b=n;
while(b >0)
{
a=b%10;
sum=sum+Math.pow(a,c);
b/=10;
c--;
}
if(n==(int)sum)
System.out.println(n+ " is A WeakArm Number");
else
System.out.println(n+ " is Not A WeakArm Number");
}
public static void main(String args[]) throws Exception
{
WA ob=new WA();
ob.showWeakArm();
}
}


This post first appeared on Tutorial Site On Computer Programming Languages F, please read the originial post: here

Share the post

BlueJ Program on Weak Arm Number

×

Subscribe to Tutorial Site On Computer Programming Languages F

Get updates delivered right to your inbox!

Thank you for your subscription

×