You cannot vote on your own question.
WAP to find and display all the special numbers between two given ranges which are accepted from the user.A special number is one whose sum of the factorial of the digits is equal to the number itself.For examle,145(1!+4!+5!=145).I have written a code but it is only giving output ad 0 and 1 no matte
static int fact(int a)
public static void main(String args)throws IOException
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter the lower range:-");
System.out.println("Enter the upper range:-");
You cannot vote on your own answer.
You just missed one single statement. Rest of your code is correct. You are adding the sum in the variable s1. Now this s1 should be re-initialized every time you enter the while loop. So, just before the while loop, add s1 = 0, and it'll work fine.
Also, these numbers are called factorions. Check this wiki page for reference: http://en.wikipedia.org/wiki/Factorion
Log in to your account to answer this questions.