Saturday, March 14, 2015

THE NUMBER IS SPECIAL NUMBER OR NOT in java



 THE NUMBER IS SPECIAL NUMBER OR NOT

 class special
{
public static long fact(int x)
{
long     i,f=1;
for (i=1;i<=x;i++)
{
f=f*i;
    }
 return f;
}
public static void main(int a)
{
special obj = new special();
long r=0,n=a,s=0;
while(a>0)
{
int k=a%10;
r=obj.fact(k);
s=s+r;
a=a/10;
    }
    if (s==n)
        System.out.println("The entered number is special");
        else
        System.out.println("The entered number is not special");
    }
}


No comments:

Post a Comment