How to identify whether narcissistic-number or not in java by jayanthi ganesh
import java.util.*;
class NarcissisticNo
{
public static void main(String []args)
{
String st = "1634";
System.out.print(getResult(st));
}
static String getResult(String st)
{
int sum = 0;
int length = st.length();
for (int i = 0; i < length; i++)
{
sum = sum + (int)Math.pow(st.charAt(i) - '0', length);
}
int number = Integer.parseInt(st);
if (number == sum)
return "yes";
else
return "no";
}
}