Skip to main content

Program to check whether a number is special or not

import java.io.*;
import java.lang.*;
class special{

static int r,n,s=0,fact=1,i;

public static void main(String args[])throws Exception{

n=Integer.parseInt(args[0]);
while(n>0)
{
r=n%10;
fact=1;
for(i=1;i<=r;i++)
fact=fact*i;
s=s+fact;
n=n/10;
}


if(Integer.parseInt(args[0])==s)
System.out.println("Special");
else
System.out.println("NOT");

}

}

Comments

Popular posts from this blog

unix commands